开发者

How to reuse existing connection in Open Session In view pattern implementation of Hibernate?

I am using Hibernate by implementing "Open Session in view" pattern?It opens a new connection per request. Is there any way to use the existing connection? Is my un开发者_JAVA百科derstanding correct? May be i miss something during implementation which cause opening of new connection?


Advice: don't implement it yourself, use an existing one, like Spring's:

Servlet 2.3 Filter that binds a Hibernate Session to the thread for the entire processing of the request. Intended for the "Open Session in View" pattern, i.e. to allow for lazy loading in web views despite the original transactions already being completed.

Failing that, look at the source code for the above to see how Spring does it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜