-->
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: Doubt in rollback
PostPosted: Mon Dec 10, 2007 11:01 am 
Newbie

Joined: Mon Dec 10, 2007 10:47 am
Posts: 3
Location: India
hai,

i have doubt in rollback concept.pls clear my doubt.

first i saved the data in the session, then i rollback again, sothat the data are not stored permenently in the database. its workking fine.

but my question is the data are not rollback in the class ie(User class).

when i print the last inserted id from the class, it print last inserted id, but that id not present in the database. bcz it already rollback. so how to rollback in the class also



see the code for clear description


User user = new User();
user.setFirstname((String)addContactForm.getFirstname());
user.setLastname((String)addContactForm.getLastname());
user.setEmail((String)addContactForm.getEmail());
session.save(user);

session.getTransaction().rollback();
System.out.println(" last inserted id"+user.getId()); // from user class.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 13, 2007 3:04 pm 
Newbie

Joined: Thu Dec 13, 2007 2:52 pm
Posts: 3
Location: Prague
Hibernate doesn't roll back in-memory changes to persistent objects. You shouldn't expect a rolled back User instance. You should discard that ISession immediately. Rollbacks are only at the database level for Hibernate.

_________________
Bahadir KONU


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.