-
1. Re: Fetching revision number before record insertion
hernanbolido Jul 19, 2010 2:05 PM (in response to richa.khurana)Hi!
The revision number for all objects in the same transaction should be the revision number from the RevisionEntity.
Regards. Hernán.
-
2. Re: Fetching revision number before record insertion
adamw Jul 20, 2010 5:09 AM (in response to hernanbolido)Exactly, and the current rev entity is available from audit reader. And it's cluster-safe.
Adam
-
3. Re: Fetching revision number before record insertion
richa.khurana Jul 20, 2010 5:36 AM (in response to adamw)Thanks a lot for your replies.
Can you elaborate more on the approach. During debugging of code I observed-
In AuditSync->getCurrentRevisionData
public Object getCurrentRevisionData(Session session, boolean persist) {
// Generating the revision data if not yet generated
if (revisionData == null) {
revisionData = revisionInfoGenerator.generate();
}// Saving the revision data, if not yet saved and persist is true
if (!session.contains(revisionData) && persist) {
revisionInfoGenerator.saveRevisionData(session, revisionData);
}return revisionData;
}We have the revision number generated only when persist is set to true, which is when we are about to flush the data. In case of steps-
1. Create record for Employee and tag_Employee entities
2. Call flush
How can I set the value of column rev=revision no of Employee_aud table in step 1 itself.
Kindly forgive my ignorance in case I am missing out on something as I am a newbie to envers.
Thanks,
Richa.
-
4. Re: Fetching revision number before record insertion
adamw Jul 20, 2010 7:02 AM (in response to richa.khurana)Please take a look at the AuditReader#
getCurrentRevision(Class<T> revisionEntityClass, boolean persist) method in http://docs.jboss.org/envers/api-new/index.html
If you call it with your revision entity's class (DefaultRevisionEnttiy.class if you don't have one) and "true", the returned object .getId() will be the current revision number.
Adam
-
5. Re: Fetching revision number before record insertion
richa.khurana Jul 21, 2010 1:13 AM (in response to adamw)Thanks a lot Adam and Hernán Chanfreau. This is exactly what i was looking for.