non-transactional

this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery(queryString)报错No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here,因为没有配置事务

        <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
            <property name="sessionFactory" ref="sessionFactory" />  
            <property name="dataSource" ref="dataSource"/>  
        </bean>  
        <tx:advice id="txAdvice" transaction-manager="txManager">  
          <tx:attributes>  
              <tx:method name="*" propagation="REQUIRED" />  
           </tx:attributes>  
        </tx:advice>  
原文地址:https://www.cnblogs.com/520future/p/8830301.html