We are using Hibernate envers to store historical revisions of the data, there is a requirement to revert data to a certain revision. As we are using the Version column to use the optimistic locking approach, when I try to save data from the previous revision I get a StaleObjectException
. Is there any way to force Hibernate to store data from previous revision?
Asked
Active
Viewed 2,928 times
16
-
Very good question. Can you show us how you're doing it? Trying to load the revision and then saving it? copying from the revision to the actual object? – Lucas de Oliveira Apr 06 '11 at 09:54
-
I am trying to load the revision and saving it using the merge method of javax.persistence.EntityManager. – Rakesh Apr 06 '11 at 10:45
-
Go through the blog. This may help. http://encodo.com/en/blogs.php?entry_id=22 – Sep 07 '11 at 08:13
1 Answers
2
That's an awesome question. I didn't find anything like that in the envers documentation but I'm sure it's a common issue. As a workaround you could set the attributes on the desired object revision (in a constructor for instance)

Lucas de Oliveira
- 1,642
- 11
- 16
-
2It is a painful workaround, but look like there is no other alternative. – Rakesh Apr 07 '11 at 17:41