| Author |
Hibernate Session Best Practice
|
Erap Estrada
Ranch Hand
Joined: Nov 08, 2006
Posts: 92
|
|
Hi guys. For a web application how many hibernate session should be opened for a one web user session? So is it like? 1 User Session = 1 Hibernate Session How would I know then on when to close a hibernate session if a user just abandoned the application without properly logging out to invalidate all sessions?
|
SCJP with 98% by...
|
 |
Edvins Reisons
Ranch Hand
Joined: Dec 11, 2006
Posts: 364
|
|
It depends on what database resources the user will access and how they are mapped. In the simple case, with one database, one Session is what you need, and how to open and close it is decided in the web or business tier of the application.
|
 |
Erap Estrada
Ranch Hand
Joined: Nov 08, 2006
Posts: 92
|
|
|
is the httpsession automatically attached to a hibernate session? So if I invalidate a httpsession, so does the hibernate session?
|
 |
Nathan Hook
Ranch Hand
Joined: Jan 10, 2005
Posts: 81
|
|
To answer your question... No once the http session is invalidated it will NOT close your hibernate session. Also, last time I checked the Hibernate team was suggesting using one hibernate session per request. (Not per http session.) I believe it is called the one hibernate session per request pattern. You should be able to find information about it (the pattern) on hibernates website. Best of Luck.
|
 |
 |
|
|
subject: Hibernate Session Best Practice
|
|
|