-->
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.  [ 8 posts ] 
Author Message
 Post subject: Rollback changes
PostPosted: Tue Oct 07, 2003 1:25 pm 
Regular
Regular

Joined: Tue Oct 07, 2003 1:13 pm
Posts: 70
Location: Paris, France
I think it's a really common question but i cant find it in the forum.
In my my webapp, I load an entity with HibernateFilter.getSession().load(myClass, id). My entity is then populated by some input parameters. Afterwards, my entity is validated. In case of errors, i would like to "rollback" the changes, I dont want when my session will be closed, the errors are persisted in db. How can I do ?
Thank you a lot.
R.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 2:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Are you using the Hibernate transaction management strategy, or utilizing JTA transactions?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 4:40 pm 
Regular
Regular

Joined: Tue Oct 07, 2003 1:13 pm
Posts: 70
Location: Paris, France
hibernate.transaction.factory_class net.sf.hibernate.transaction.JDBCTransactionFactory

Thank you for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 5:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
If you don't have a handle to the transaction (i.e, you never called session.beginTransaction()), you can try evicting the instance from session (session.evict()) prior to flushing.

Otherwise, just call transaction.rollback()


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 7:22 pm 
Regular
Regular

Joined: Tue Oct 07, 2003 1:13 pm
Posts: 70
Location: Paris, France
If i use a transaction, s.beginTransaction(), a rollback cancels only the flushing to db ? You have to discard the session ? Im right ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 8:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
You have to discard the session?

What makes you say that?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2003 12:11 pm 
Regular
Regular

Joined: Tue Oct 07, 2003 1:13 pm
Posts: 70
Location: Paris, France
I tried the evict() method, but unfortunately i cant understand Hibernate flushes automatically my entity as soon as its has been modified, and COMMIT it (whitout any intervention from me) , so evict() becomes useless. Can you explain me ?

Here is my conf :
Hibernate 2.1b4
Proxool
Postgresql 7.3

Thank you for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2003 1:03 pm 
Regular
Regular

Joined: Tue Oct 07, 2003 1:13 pm
Posts: 70
Location: Paris, France
I resolved my problem with a session.setFlushMode(FlushMode.COMMIT).
Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.