use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class DoubleFlushModMod method testHistoryOfId.
@Test
public void testHistoryOfId() {
StrTestEntity ver1 = new StrTestEntity("x", id);
StrTestEntity ver2 = new StrTestEntity("z", id);
assert getAuditReader().find(StrTestEntity.class, id, 1).equals(ver1);
assert getAuditReader().find(StrTestEntity.class, id, 2).equals(ver2);
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class ManualFlush method testHistoryOfId.
@Test
public void testHistoryOfId() {
StrTestEntity ver1 = new StrTestEntity("x", id);
StrTestEntity ver2 = new StrTestEntity("z", id);
assertEquals(ver1, getAuditReader().find(StrTestEntity.class, id, 1));
assertEquals(ver2, getAuditReader().find(StrTestEntity.class, id, 2));
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class DetachedTest method testUpdatingDetachedEntityWithRelation.
@Test
@Priority(10)
@TestForIssue(jiraKey = "HHH-7543")
public void testUpdatingDetachedEntityWithRelation() {
Session session = getSession();
// Revision 1
session.getTransaction().begin();
ListRefCollEntity parent = new ListRefCollEntity(1, "initial data");
StrTestEntity child = new StrTestEntity("data");
session.save(child);
parent.setCollection(Arrays.asList(child));
session.save(parent);
session.getTransaction().commit();
session.close();
session = getSession();
// Revision 2 - updating detached entity
session.getTransaction().begin();
parent.setData("modified data");
session.update(parent);
session.getTransaction().commit();
session.close();
parentId = parent.getId();
childId = child.getId();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class DetachedTest method testHistoryOfParent.
@Test
public void testHistoryOfParent() {
ListRefCollEntity parent = new ListRefCollEntity(parentId, "initial data");
parent.setCollection(Arrays.asList(new StrTestEntity("data", childId)));
ListRefCollEntity ver1 = getAuditReader().find(ListRefCollEntity.class, parentId, 1);
Assert.assertEquals(parent, ver1);
Assert.assertEquals(parent.getCollection(), ver1.getCollection());
parent.setData("modified data");
ListRefCollEntity ver2 = getAuditReader().find(ListRefCollEntity.class, parentId, 2);
Assert.assertEquals(parent, ver2);
Assert.assertEquals(parent.getCollection(), ver2.getCollection());
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class QueryingWithProxyObjectTest method testQueryingWithProxyObject.
@Test
@TestForIssue(jiraKey = "HHH-4760")
@SuppressWarnings("unchecked")
public void testQueryingWithProxyObject() {
StrTestEntity originalSte = new StrTestEntity("data", id);
// Load the proxy instance
StrTestEntity proxySte = (StrTestEntity) getSession().load(StrTestEntity.class, id);
Assert.assertTrue(getAuditReader().isEntityClassAudited(proxySte.getClass()));
StrTestEntity ste = getAuditReader().find(proxySte.getClass(), proxySte.getId(), 1);
Assert.assertEquals(originalSte, ste);
List<Number> revisions = getAuditReader().getRevisions(proxySte.getClass(), proxySte.getId());
Assert.assertEquals(Arrays.asList(1), revisions);
List<StrTestEntity> entities = getAuditReader().createQuery().forEntitiesAtRevision(proxySte.getClass(), 1).getResultList();
Assert.assertEquals(Arrays.asList(originalSte), entities);
ste = (StrTestEntity) getAuditReader().createQuery().forRevisionsOfEntity(proxySte.getClass(), true, false).getSingleResult();
Assert.assertEquals(originalSte, ste);
ste = (StrTestEntity) getAuditReader().createQuery().forEntitiesModifiedAtRevision(proxySte.getClass(), 1).getSingleResult();
Assert.assertEquals(originalSte, ste);
}
Aggregations