天天看点

org.hibernate.HibernateException: createSQLQuery is not valid without active transaction

org.hibernate.HibernateException: createSQLQuery is not valid without active transaction

异常解决: 产生这个异常的原因是代码中使用了如下片段:

public class ConfigDaoImpl extends HibernateBaseTemplate implements ConfigDao {.........

this.getHibernateTemplate().getSessionFactory().getCurrentSession();

=====================

由于配置文件中是如下的用法:

   <property name="current_session_context_class">thread</property>

如果改为:

  <property name="current_session_context_class">jta</property>

则没问题.

[参照:http://blog.csdn.net/yinjian520/article/details/8666695]