-->
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: Envers revert revision
PostPosted: Fri Apr 05, 2013 9:11 am 
Newbie

Joined: Fri Jan 13, 2012 11:14 am
Posts: 3
So now that I enabled this fancy envers and gotten myself some revisions. I'm ready for some complex that should've been easy.

Let me explain the setup and why I need this:

I have 2 threads, each their own hibernate session

Thread A, with Session A does some database changes. Then queue's some stuff to be handled by Thread B, Thread A will wait on the result of Thread B's work.
Thread B, will need to actual updated database changes from Thread A, so Thread A commits to database. Thus forfeiting any rollback transaction I could have done.
Incase an error occurs in Thread B I will need to revert the changes done in Thread A to the database reverted.

My first thought to this problem was, Hey we use envers, it creates revisions, so why can't we use that to revert to a revision?
Google didn't help on this "hibernate envers rollback to revision" query results into only other people asking the same question...

So my 2nd thought was, ok then I'll probably have to implement it myself.

Normal process continues as described above until error in Thread B occurs and is received by Thread A.

Now I'm in need of all revisions that are made by Thread A, so I can use CrossTypeRevisionChangesReader.findEntities(Number revision) http://docs.jboss.org/hibernate/orm/4.1/javadocs/org/hibernate/envers/CrossTypeRevisionChangesReader.html#findEntities(java.lang.Number) to find all objects changed and use Session.merge(object) to restore the state of the object(s) changed to a state before Thread A started doing it's changes.

Anyhow to achieve this should've been easy task?


Top
 Profile  
 
 Post subject: Re: Envers revert revision
PostPosted: Fri Apr 12, 2013 3:48 am 
Newbie

Joined: Fri Jan 13, 2012 11:14 am
Posts: 3
*boink*


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.