org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not
来源:互联网 发布:卡五星麻将app源码 编辑:程序博客网 时间:2024/05/17 21:59
first of all if you want to use getcurrentSession() method you need to add these properties to HibernateProperties:
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
添加后如下:
- <bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="dataSource" ref="dataSource"></property>
- <property name="configurationClass">
- <value>org.hibernate.cfg.AnnotationConfiguration</value>
- </property>
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">
- org.hibernate.dialect.Oracle9Dialect
- </prop>
- <prop key="hibernate.show_sql">true</prop>
- <prop key="hibernate.current_session_context_class">thread</prop>
- <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
- </props>
- </property>
- <property name="mappingResources">
- <list>
- Log.hbm.xml</value>
- </list>
- </property>
- </bean>
second thing is from the exception, Hibernate3 doesn't allow you to run queries without starting a transaction. you have to add this to your init method before running the query:
sessionFactory.getCurrentSession().beginTransactio n();
and of course commit it in the end of your unit of work.
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a
- 继承类的@Transactional:org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow crea
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transac
- HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and
- ssh 中报错:org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration
- No Hibernate Session boundNo Hibernate Session bound to thread, and configuration does not allow cr
- Spring+Hibernate 异常No Hibernate Session bound to thread, and configuration does not allow creation
- org.hibernate.HibernateException: No Hibernate Session bound to thread
- org.hibernate.HibernateException: No Hibernate Session bound to thread
- org.hibernate.HibernateException: No Hibernate Session bound to thread
- No Hibernate Session bound to thread, and configuration does not allow creation of non-transactiona
- No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional
- 三种方法绑定三列数据
- linux 下 avr开发环境的搭建
- Myeclipse中导入Android项目时,提示的错误:unable to resolve target 'android-14'
- 消除下载Android源码时的“curl: (7)”等错误
- UBUNTU添加开机自动启动程序方法
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not
- hdu 1010 Tempter of the Bone(DFS奇偶性剪枝+多重剪枝)
- MindNode.app 思维导图 下载是Pro版哦
- org.hibernate.exception.GenericJDBCException: Cannot open connection
- A+B Problem新解
- C++文件流_矩阵相乘
- shell脚本学习-为什么使用 shell 编程
- scrollTo、scrollBy、getScrollX、getScrollY这4个方法的含义
- thunderbird邮箱备份方法