【发布时间】:2013-04-30 06:53:00
【问题描述】:
我正在使用hibernate并且在如何使用会话时遇到了一些麻烦,这是最好的方法:
-
使用一个会话并在单例中打开它
public static CommonServiceImpl getInstance() { if (session == null || !session.isOpen() ) { session = sessionFactory.openSession(); } //session.clear(); return instance; } 每次我想使用
sessionFactory.getCurrentSession()的会话时使用SessionFactory?
【问题讨论】:
标签: hibernate session sessionfactory