use of org.hibernate.envers.test.integration.auditReader.AuditedTestEntity in project hibernate-orm by hibernate.
the class HasChangedAPITest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();
AuditedTestEntity ent1 = new AuditedTestEntity(1, "str1");
NotAuditedTestEntity ent2 = new NotAuditedTestEntity(1, "str1");
em.persist(ent1);
em.persist(ent2);
em.getTransaction().commit();
em.getTransaction().begin();
ent1 = em.find(AuditedTestEntity.class, 1);
ent2 = em.find(NotAuditedTestEntity.class, 1);
ent1.setStr1("str2");
ent2.setStr1("str2");
em.getTransaction().commit();
}
use of org.hibernate.envers.test.integration.auditReader.AuditedTestEntity in project hibernate-orm by hibernate.
the class HasChangedAPITest method testHasChangedHasNotChangedCriteria.
@Test
public void testHasChangedHasNotChangedCriteria() throws Exception {
List list = getAuditReader().createQuery().forRevisionsOfEntity(AuditedTestEntity.class, true, true).add(AuditEntity.property("str1").hasChanged()).getResultList();
assertEquals(2, list.size());
assertEquals("str1", ((AuditedTestEntity) list.get(0)).getStr1());
assertEquals("str2", ((AuditedTestEntity) list.get(1)).getStr1());
list = getAuditReader().createQuery().forRevisionsOfEntity(AuditedTestEntity.class, true, true).add(AuditEntity.property("str1").hasNotChanged()).getResultList();
assertTrue(list.isEmpty());
}
Aggregations