-->
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: Do FlushMode.MANUAL can rollback transaction.
PostPosted: Wed Mar 05, 2008 10:02 am 
Newbie

Joined: Wed Mar 05, 2008 10:01 am
Posts: 3
I have something like this:

Code:

try{

MyClass myClass = new MyClass();
dao.save(myClass);
sf.getCurrentSession().flush(); // Saving object.

// In this place I’m using PreparedStatement to save some data, I’m creating sql and
// executing. During creating sql I’m pass id myClass (create relation one to many).

} catch (Exception ex) {
// Now if appear some error during executing sql I wont rollback all also myClass.
// so I call.
   sf.getCurrentSession().setFlushMode(FlushMode.MANUAL);      
}



But this method rollback only sql executed through PreparedStatement, myClass is still in database, why? Can I rollback all using FlushMode.MANUAL.

I know I can use “dao.getSession().beginTransaction();” before TRY and “dao.getSession().getTransaction().rollback();” in catch and all is rollback, but can I do this using “FlushMode.MANUAL”


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.