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: how to define transaction boundary
PostPosted: Sun Sep 07, 2008 11:36 pm 
Newbie

Joined: Sun Sep 07, 2008 11:26 pm
Posts: 1
Hibernate version: 2.0

Code:
Session session = sessionFactory.openSession();
t1 = session.BeginTransaction();
session.save(obj1);
t1.commit();

obj1.propty = "XXXX";

t2 = session.BeginTransaction();
session.save(obj2);
t2.commit();
session.close();



My problem is when t2.commit(); it also changes the value of obj1, however, I don't want this. I just want transaction commit the save/update/delete action after the transaction is decleared. Is it possible to prevent obj1 change without evict the obj from current session. that is, control the save and update action with in transaction level but not session.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 08, 2008 1:42 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
No, the transaction always commits the whole session. You can either use different sessions or evict the object.

_________________
--Wolfgang


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.