-->
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 and Transaction scope
PostPosted: Tue Aug 24, 2004 4:59 am 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
Hi,

A little design quesion, after reading http://www.hibernate.org/168.html [Session and Transaction scope] I am a bit confused how to destinquish the session-per-application-transaction and the anti-pattern session-per-application.

Let's give a simple example (implemented with servlets/jsp):
User logs in to website.
User opens his shoppingcart.
User adds a product.
User goes to checkout.
User leaves the browser and servlet waits till timeout.

What is good by design? I would suggest:
1. Retrieve a Hibernate Session and place it in a Threadlocal.
2. Retrieve the cart of the user from the session and place it in the servlet session object.
2. Retrieve a product from the session and add it to the cart.
3. Update the cart with the session.
4. On timeout of the httpsession close the hibernate session.

This looks like the session-per-application anti-pattern. Can somebody please give me a description on how this should be solved.

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 24, 2004 5:01 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read the definition of "application transaction" again, what you are doing is not in a single app transaction. It's an anti-pattern.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.