首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在connection.release_mode (spring + hibernate)中设置不同的值然后设置'auto‘

如何在connection.release_mode (spring + hibernate)中设置不同的值然后设置'auto‘
EN

Stack Overflow用户
提问于 2012-11-05 05:17:44
回答 1查看 3.8K关注 0票数 0

是否可以为hibernate属性设置一个不同的值,然后设置为'auto‘-- "connection.release_mode"?

我们使用Spring和hibernate,当我试图在这个属性中定义'after_transaction‘(当我在会话工厂定义中定义hibernate属性时),在运行时我得到一个异常(Spring异常),这个属性的唯一有效值(在Spring术语中)是'on_close’。这个事实给我们带来了很多麻烦。我们使用session-per-request模式(意思是“客户端向运行Hibernate持久层的服务器发送请求。Hibernate打开一个新的会话,所有数据库操作都在这个工作单元中执行。”(hibernate doc )。定义on_close时-为每个服务分配连接(不会重复使用连接)。

我们结合TransactionInterceptor使用HibernateTransactionManager来管理事务。我们使用AnnotationSessionFactoryBean (我们的会话工厂)来处理会话,我尝试在"hibernateProperties“部分-> connection.release_mode=after_transaction中的会话工厂解密中定义。在运行时,当服务器尝试加载会话工厂时,我得到了这个异常:

代码语言:javascript
复制
org.springframework.transaction.InvalidIsolationLevelException: HibernateTransactionManager is not allowed to support custom isolation levels: make sure that its 'prepareConnection' flag is on (the default) and that the Hibernate connection release mode is set to 'on_close' (SpringTransactionFactory's default). Make sure that your LocalSessionFactoryBean actually uses SpringTransactionFactory: Your Hibernate properties should *not* include a 'hibernate.transaction.factory_class' property!
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:515)
    ... 121 more

为什么春天会这样呢?有旁路吗?

任何建议都将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2017-10-11 20:51:41

要设置不同的连接释放模式,必须创建一个文件

src/main/resources/hibernate.properties

并设置该值

hibernate.connection.release_mode=AFTER_STATEMENT

其他可用值可在here 中找到

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13223019

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档