use of org.hibernate.envers.DefaultRevisionEntity in project hibernate-orm by hibernate.
the class TestConsole method printPersonHistory.
private void printPersonHistory(StringBuilder sb, int personId) {
AuditReader reader = AuditReaderFactory.get(entityManager);
List personHistory = reader.createQuery().forRevisionsOfEntity(Person.class, false, true).add(AuditEntity.id().eq(personId)).getResultList();
if (personHistory.size() == 0) {
sb.append("A person with id ").append(personId).append(" does not exist.\n");
} else {
for (Object historyObj : personHistory) {
Object[] history = (Object[]) historyObj;
DefaultRevisionEntity revision = (DefaultRevisionEntity) history[1];
sb.append("revision = ").append(revision.getId()).append(", ");
printPerson(sb, (Person) history[0]);
sb.append(" (").append(revision.getRevisionDate()).append(")\n");
}
}
}
use of org.hibernate.envers.DefaultRevisionEntity in project hibernate-orm by hibernate.
the class TestConsole method printAddressHistory.
private void printAddressHistory(StringBuilder sb, int addressId) {
AuditReader reader = AuditReaderFactory.get(entityManager);
List addressHistory = reader.createQuery().forRevisionsOfEntity(Address.class, false, true).add(AuditEntity.id().eq(addressId)).getResultList();
if (addressHistory.size() == 0) {
sb.append("A address with id ").append(addressId).append(" does not exist.\n");
} else {
for (Object historyObj : addressHistory) {
Object[] history = (Object[]) historyObj;
DefaultRevisionEntity revision = (DefaultRevisionEntity) history[1];
sb.append("revision = ").append(revision.getId()).append(", ");
printAddress(sb, (Address) history[0]);
sb.append(" (").append(revision.getRevisionDate()).append(")\n");
}
}
}
use of org.hibernate.envers.DefaultRevisionEntity in project hibernate-orm by hibernate.
the class GetRevisionsCommand method execute.
public Object execute(CommandSession session) throws Exception {
Map<Number, DefaultRevisionEntity> revisions = dpService.getRevisions(Long.valueOf(id));
for (Number revisionNum : revisions.keySet()) {
DefaultRevisionEntity dre = revisions.get(revisionNum);
System.out.println(revisionNum + ": " + dre.getId() + ", " + dre.getTimestamp());
}
return null;
}
use of org.hibernate.envers.DefaultRevisionEntity in project wildfly by wildfly.
the class ImplementValidityAuditStrategyTestCase method testValidityStrategyActivationforEnvers.
@Test
@InSequence(2)
public void testValidityStrategyActivationforEnvers() throws Exception {
SLSBValidityStrategyOrg slsbvalidityOrg = lookup("SLSBValidityStrategyOrg", SLSBValidityStrategyOrg.class);
Organization o1 = slsbvalidityOrg.createOrg("REDHAT", "Software Co", "10/10/1994", "eternity", "Raleigh");
Organization o2 = slsbvalidityOrg.createOrg("HALDIRAMS", "Food Co", "10/10/1974", "eternity", "Delhi");
o2.setStartDate("10/10/1924");
o2.setName("BIKANER");
slsbvalidityOrg.updateOrg(o2);
// check if REV END Date is populated
List<Map<String, Object>> orgHistory = slsbvalidityOrg.verifyEndRevision(new Integer(o2.getId()));
for (Map<String, Object> revisionEntity : orgHistory) {
Assert.assertNotNull(revisionEntity);
Date revendTimestamp = (Date) revisionEntity.get("REVEND_VALIDITY");
DefaultRevisionEntity revEnd = (DefaultRevisionEntity) revisionEntity.get("REVEND");
if (revendTimestamp != null) {
Assert.assertEquals(revendTimestamp.getTime(), revEnd.getTimestamp());
}
}
}
Aggregations