开发者

Hibernate session management for multiple transactions ?

What is the best way for maintaning Hibernate session for multiple database transa开发者_C百科ctions? Do I need to open and close each session every time or should I rely upon getCurrentSession()? Whats the best approach?


I think, the best approach will be to obtain sessions via openSession() and release them via disconnect(). This will cause the database connection to be returned to the Hibernate connection pool, and thus, if you're not executing all trasactions at once, your sessions will be created from the existing connections (where possible) and overall performance will be sane.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜