16

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?

Brad Mace
  • 27,194
  • 17
  • 102
  • 148
Rakesh
  • 365
  • 4
  • 8
  • 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 Answers1

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