-->
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: EntityManager and extended conversations
PostPosted: Fri Feb 23, 2007 3:45 pm 
Regular
Regular

Joined: Thu Sep 23, 2004 11:53 am
Posts: 83
Hibernate version:
3
Mapping documents:
NA
Code between sessionFactory.openSession() and session.close():
NA
Full stack trace of any exception that occurs:
NA
Name and version of the database you are using:
NA
The generated SQL (show_sql=true):
NA
Debug level Hibernate log excerpt:
NA

The example below is not very clear. With Hibernate this seems straight foward because of it use of disconnected entites and the session being closed/opened on every request. With JPDA, how would one handle the fact that within an extended session (conversation) that may never make to the point where em.close() is called? An example would be a wizard where there are 3 steps ... (1) the entity manager is set (2) the user updates some entities (3) the user never clicks to finalize the changes. So if the user never finalizes the changes then em.close() is never called what happens then?

Code:
// Begin persistence context and conversation
EntityManager em = emf.createEntityManager();
ManageAuctionExtended controller = new ManageAuctionExtended(em);
// First event
Item item = controller.getAuction( 1234l );
// Item is displayed on screen and modified...
item.setDescription("[SOLD] An item for sale");
// Second event
controller.endAuction(item);
// End persistence context and conversation
em.close();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 23, 2007 4:18 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Nothing happens, unless you use Seam (http://www.jboss.com/products/seam/), which has an automatic conversation state timeout mechanism. Note that it doesn't matter if the not-cleaned-up conversation state is detached entities or a non-closed persistence context. Both strategies leave garbage in the users session state (the "outer" state, where all the conversation states live in) that needs to be cleaned up.

_________________
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.