-->
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.  [ 1 post ] 
Author Message
 Post subject: Transaction versus Session
PostPosted: Mon Nov 05, 2007 5:35 pm 
Newbie

Joined: Thu Oct 25, 2007 3:37 pm
Posts: 17
My understanding of the persistent context is that it is equal to the session. But I'm a bit confused. What happens in the following code?

Code:
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();

User user = session.load(User.class, new Long(1234) );
user.setName( 'Billy');

tx.commit();

user.setName( "jimmy' );

Transaction tx2 = session.beginTransaction();
tx2.commit();

session.close();



So, if the session was never closed, then user was not detached? At least that's how I understand it. Does this mean that the name will be set to Jimmy in the DB?


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

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.