-
1. Re: How to find out whether audit recorded the current transaction?
adamw Jun 9, 2011 9:27 AM (in response to wallenborn)In fact the audit entries are only written when the transaction commits, not "on-the-fly"; that way Envers knows exactly what was changed (it's possible to modify an entity and revert it in one tx).
But your use case is quite interesting ... you could try doing a session.flush() or entityManager.flush() and looking at the rev entity then?
Adam
-
2. Re: How to find out whether audit recorded the current transaction?
wallenborn Jun 9, 2011 1:47 PM (in response to adamw)This works:
public void storeEntity(SomeEntity e) {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
RevisionEntity re = AuditReaderFactory.get(entityManager).getCurrentRevision(RevisionEntity.class, false);
dao.saveOrUpdate(em, e);
em.getTransaction().commit();
em.close();
if (re.getId())
log.info("Entity e changed, changed version was stored in database");
else
log.info("RevisionEntity id is null");
}
so maybe it's just my transaction management that's messed up a little.