-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: session-per-request or session-per-transaction?
PostPosted: Mon Jan 18, 2010 2:24 am 
Newbie

Joined: Mon Jan 18, 2010 2:19 am
Posts: 1
Let's say I have a website with a rather large number of visits, perhaps 10-20 per second with occasional brief spikes of 10 times that or so. Strictly from a performance perspective, is there a measurable downside to keeping Hibernate sessions open for the entire length of the request? The documentation seems to indicate that opening a Hibernate session at the repository level is an anti-pattern, especially if you're going to be making more than one repository call, but perhaps I could carefully fine-tune my session openings at the level of some aggregate service. Is there a general best practice that I should default to?


Top
 Profile  
 
 Post subject: Re: session-per-request or session-per-transaction?
PostPosted: Mon Jan 18, 2010 9:32 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I'd actually say that each request is often a single transaction. I mean, a client wants data, and you need to send them the data they want, or they want to update data, and they want to know it was all updated properly. Each is a request, and each should be a single transaction. So, most of the time, it's a single transaction per request, which also implies a single session per request.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.