小编Per*_*123的帖子

Hibernate session.close()没有返回到池的连接

我的应用程序已经长期运行的事务,因此我想在每一个方法的末尾选择session.close(),以确保连接对象不长的时间无限期持有.

当使用session.close()选项时,我可以看到Hibernate的会话对象和从session.connection()获得的相应Connection对象被正确销毁.但问题在于连接池.即使在关闭会话后,会话获得的连接也不会释放回连接池.其他请求等待从池中连接.

我在我的应用程序中使用JTA事务.在hibernate.cfg.xml中,我将connection.release_mode设置为auto(默认值),将connection.autocommit设置为true.

有人遇到过这个问题吗?请让我知道我在这里失踪了什么.

后续:这是我的hibernate配置文件详细信息:

<property name="connection.datasource">MXoraDS</property> 
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property> 
<property name="connection.release_mode">after_statement</property> 
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property> 
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.JTASessionContext</property> 
<property name="transaction.auto_close_session">true</property> 
<property name="max_fetch_depth">2</property>
Run Code Online (Sandbox Code Playgroud)

我们在连接到Oracle DB的应用程序层使用JSF和EJB 2.1.在after_statement似乎没有释放到连接池.如果您需要更多详细信息,请与我们联系.

session hibernate ejb jta

14
推荐指数
2
解决办法
4万
查看次数

标签 统计

ejb ×1

hibernate ×1

jta ×1

session ×1