[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

Hibernate error

Asked by RealWorld in Spring, J2EE Frameworks

Tags: hibernate, spring, spring-beans

Hello all, I'm trying to invoke method based on some interval time, here are some beans inside applicationContext.xml, anyone knows what is this all about, any suggestions ? thank you, I also found this but its not of much help to me http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
<bean id="MngtTarget"
  class="com.management.engine.Implementation" 
  abstract="false" lazy-init="true" autowire="default" dependency-check="default">
 
    <bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject" ref="MngtTarget" />
      <property name="targetMethod" value="findItemByPIdEndDate"/>
    </bean>
 
 
    <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
 
        <property name="jobDetail" ref="jobDetail" />
        <!-- 10 seconds -->
        <property name="startDelay" value="10000" />
        <!-- repeat every 50 seconds -->
        <property name="repeatInterval" value="20000" />
    </bean>
 
 
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="simpleTrigger" />
            </list>
        </property>
    </bean>
 
//Here is the method I'm trying to invoke :
 
public List<Long> I need findItemByPIdEndDate() throws Exception {
 
                List<Long> list = null;
 
                try{
                        Session session = sessionFactory.getCurrentSession();
 
                        Query query = session.getNamedQuery("endDateChecker");
                        list =  query.list();
 
                        for(int i=0; i<list.size(); i++)
                        {
                                System.out.println(list.get(i));
                        }
 
                        System.out.println("Total " + list.size());
 
                }catch (HibernateException e){
                        throw new DataAccessException(e.getMessage());
                }
 
                return list;
        }
 
 
//Here is the exception message that I get :
 
Invocation of method 'findItemByPIdEndDate' on target class [class com.management.engine.Implementation] failed; nested exception is No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
 
 
//I've spent time googling alot so far also I've tried to modify my method like this :
 
public List<Long> I need findItemByPIdEndDate() throws Exception {
 
                    List<Long> list = null;
 
                    try{
                            Session session = sessionFactory.openSession();
 
                            Query query = session.getNamedQuery("endDateChecker");
                            list =  query.list();
 
                            for(int i=0; i<list.size(); i++)
                            {
                                    System.out.println(list.get(i));
                            }
 
                            System.out.println("Total " + list.size());
                            session.close();
                    }catch (HibernateException e){
                            throw new DataAccessException(e.getMessage());
                    }
 
                    return list;
            }
 
 
//And I get different error msg, I get : Invocation of method 'findItemByPIdEndDate' on target class [class com.management.engine.Implementation] failed; nested exception is could not execute query] 
 
//Also my queries.hbm.xml
 
<hibernate-mapping>
 
<sql-query name="endDateChecker">
<return-scalar column="PId" type="java.lang.Long"/>
      <![CDATA[select
   item_pid as PId
     from
         item
        where
        end_date < trunc(sysdate)]]>      
 </sql-query> 
</hibernate-mapping>
[+][-]10/26/09 03:22 AM, ID: 25660860Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/26/09 03:26 AM, ID: 25660881Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/26/09 04:39 AM, ID: 25661219Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/26/09 10:52 AM, ID: 25664832Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/26/09 11:00 AM, ID: 25664908Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/26/09 11:03 AM, ID: 25664932Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625