• Post Reply Bookmark Topic Watch Topic
  • New Topic

Does it really matter to use diffrent hibernate session for one web app thread ?  RSS feed

Raj Ohadi
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we use web application to call hibernate code to retrieve some object like user profile, then user can edit it and then our code can sync it back to database using hibernate. Procedure like --

Profile myPro = ProfileDAO.get(..) // line 1
myPro.set(..); myPro.set(..);
profileDAO.update(myPro); // line 3

so if in the ProfileDAO class we have

public get(..) {
try { openSession();...close();}

public update(..) {
try { openSession();...; close();}

Then we are using 2 different Sessions for line 1 and line 3. But WHY do we really care about it ? I don't get it. We have closed the previous one so there is no memory leak problem. Why do we care ?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!