views:

221

answers:

1

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 understanding correct? May be i miss something during implementation which cause opening of new connection?

+1  A: 

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.

skaffman
Thanks @skaffman, i regret for myself for not posting this question earlier.
Shashi Bhushan

related questions