title: Problem with spring quartz
body: <p>I'm trying to invoke method based on some interval time, here are some beans inside applicationContext.xml</p>
  
  <pre><code>&lt;bean id="MngtTarget"
    class="com.management.engine.Implementation" 
    abstract="false" lazy-init="true" autowire="default" dependency-check="default"&gt;
  
      &lt;bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"&gt;
        &lt;property name="targetObject" ref="MngtTarget" /&gt;
        &lt;property name="targetMethod" value="findItemByPIdEndDate"/&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"&gt;
  
          &lt;property name="jobDetail" ref="jobDetail" /&gt;
          &lt;!-- 10 seconds --&gt;
          &lt;property name="startDelay" value="10000" /&gt;
          &lt;!-- repeat every 50 seconds --&gt;
          &lt;property name="repeatInterval" value="20000" /&gt;
      &lt;/bean&gt;
  
  
      &lt;bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt;
          &lt;property name="triggers"&gt;
              &lt;list&gt;
                  &lt;ref bean="simpleTrigger" /&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>Here is the method I'm trying to invoke :</p>
  
  <pre><code>public List&lt;Long&gt; I need findItemByPIdEndDate() throws Exception {
  
                  List&lt;Long&gt; list = null;
  
                  try{
                          Session session = sessionFactory.getCurrentSession();
  
                          Query query = session.getNamedQuery("endDateChecker");
                          list =  query.list();
  
                          for(int i=0; i&lt;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;
          }
  </code></pre>
  
  <p>Here is the exception message that I get :</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I've spent time googling alot so far also I've tried to modify my method like this :</p>
  
  <pre><code> public List&lt;Long&gt; I need findItemByPIdEndDate() throws Exception {
  
                      List&lt;Long&gt; list = null;
  
                      try{
                              Session session = sessionFactory.openSession();
  
                              Query query = session.getNamedQuery("endDateChecker");
                              list =  query.list();
  
                              for(int i=0; i&lt;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;
              }
  </code></pre>
  
  <p>And I get different error msg, I get : <code>Invocation of method 'findItemByPIdEndDate' on target class [class com.management.engine.Implementation] failed; nested exception is could not execute query]</code> , anyone knows what is this all about, any suggestions ? thank you</p>
  
  <p>Also my queries.hbm.xml</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
  
  &lt;sql-query name="endDateChecker"&gt;
  &lt;return-scalar column="PId" type="java.lang.Long"/&gt;
        &lt;![CDATA[select
     item_pid as PId
       from
           item
          where
          end_date &lt; trunc(sysdate)]]&gt;      
   &lt;/sql-query&gt; 
  &lt;/hibernate-mapping&gt;
  </code></pre>