use of org.hibernate.envers.AuditReader in project Asqatasun by Asqatasun.
the class ProcessResultDAOImpl method getHistoryChanges.
@Override
public List<DefiniteResult> getHistoryChanges(ProcessResult processResultImpl) {
List<DefiniteResult> history = new ArrayList<>();
AuditReader auditReader = AuditReaderFactory.get(this.entityManager);
Long id = processResultImpl.getId();
if (id == null) {
return new ArrayList<>();
}
List<Number> revisions = auditReader.getRevisions(processResultImpl.getClass(), id);
DefiniteResult find;
for (int i = 0; i < revisions.size(); i++) {
Number revision = revisions.get(i);
find = auditReader.find(DefiniteResultImpl.class, id, revision);
history.add(find);
}
return history;
}
use of org.hibernate.envers.AuditReader in project hibernate-orm by hibernate.
the class HibernateEnversOnWildflyTest method testEnversCompatibility.
@Test
public void testEnversCompatibility() throws Exception {
// revision 1
userTransaction.begin();
entityManager.joinTransaction();
AuditedEntity entity = new AuditedEntity(1, "Marco Polo");
entityManager.persist(entity);
userTransaction.commit();
// revision 2
userTransaction.begin();
entityManager.joinTransaction();
entity.setName("George Washington");
entityManager.merge(entity);
userTransaction.commit();
entityManager.clear();
// verify audit history revision counts
userTransaction.begin();
final AuditReader auditReader = AuditReaderFactory.get(entityManager);
assertEquals(Arrays.asList(1, 2), auditReader.getRevisions(AuditedEntity.class, 1));
userTransaction.commit();
}
use of org.hibernate.envers.AuditReader in project wildfly by wildfly.
the class SFSBHibernateEnversSessionFactory method retrieveOldStudentVersion.
// fetch Audited entity from Audit tables
public StudentAudited retrieveOldStudentVersion(int id) {
AuditReader reader = AuditReaderFactory.get(sessionFactory.openSession());
StudentAudited student_rev = reader.find(StudentAudited.class, id, 1);
List<Number> revlist = reader.getRevisions(StudentAudited.class, id);
// this is for checking revision size hence not removing this S.o.p
return student_rev;
}
use of org.hibernate.envers.AuditReader in project wildfly by wildfly.
the class SFSB1 method retrieveOldEmployeeVersionforRollBack.
public String retrieveOldEmployeeVersionforRollBack(int id) {
AuditReader reader = AuditReaderFactory.get(em);
Employee emp1_rev = reader.find(Employee.class, id, 5);
return emp1_rev.getAddress();
}
use of org.hibernate.envers.AuditReader in project wildfly by wildfly.
the class SLSBAudit method verifyRevision.
public List<Object> verifyRevision(int id) {
AuditReader reader = AuditReaderFactory.get(em);
// boolean b;
// String queryString = "select a.originalId.REV from " + "CUSTOMER_PHONE" + "_AUD a";
// String queryString = "select column_name from information_schema.columns where table_name = 'CUSTOMER_PHONE_AUD'";
// Query query = em.createQuery(queryString);
List<Object> custHistory = new ArrayList<Object>();
List<Number> revList = reader.getRevisions(Customer.class, id);
for (Number revisionNumber : revList) {
AuditQuery query = reader.createQuery().forEntitiesAtRevision(Customer.class, revisionNumber);
query.add(AuditEntity.property("firstname").eq("MADHUMITA"));
if (query.getResultList() != null && query.getResultList().size() > 0) {
custHistory.add(query.getResultList());
}
}
return custHistory;
}
Aggregations