关闭Hibernate连接 [英] Closing Hibernate Connection
本文介绍了关闭Hibernate连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我为 DB
池使用 Hibernate
。连接没有正确关闭。我打电话给:
I am using Hibernate
for DB
pooling. Connections are not closing properly. I am calling this:
HibernateManager.getSessionFactory().getCurrentSession().disconnect();
请帮我解决。
Please help me out.
推荐答案
Session.disconnect()
不符合您的想法:
Session.disconnect()
does not do what you think it does:
断开与其基础JDBC连接的会话。这适用于应用程序向会话提供JDBC连接并需要长时间会话(又名会话)的情况。
Disconnect the session from its underlying JDBC connection. This is intended for use in cases where the application has supplied the JDBC connection to the session and which require long-sessions (aka, conversations).
通常,您只想关闭()Session或让事务管理层处理获取和关闭连接。
Typically you just want to either close() the Session or let the transaction management layer handle getting and closing connections.
这篇关于关闭Hibernate连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文