Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate Envers Revert data to a version

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?

like image 895
Rakesh Avatar asked Apr 06 '11 09:04

Rakesh


1 Answers

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)

like image 198
Lucas de Oliveira Avatar answered Sep 27 '22 23:09

Lucas de Oliveira