use of org.hibernate.envers.test.integration.basic.BasicTestEntity1 in project hibernate-orm by hibernate.
the class HasChangedManualFlush method testHasChangedOnDoubleFlush.
@Test
public void testHasChangedOnDoubleFlush() {
List list = queryForPropertyHasChanged(BasicTestEntity1.class, id, "str1");
assertEquals(2, list.size());
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
list = queryForPropertyHasChanged(BasicTestEntity1.class, id, "long1");
assertEquals(2, list.size());
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
}
use of org.hibernate.envers.test.integration.basic.BasicTestEntity1 in project hibernate-orm by hibernate.
the class HasChangedManualFlush method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1
em.getTransaction().begin();
BasicTestEntity1 entity = new BasicTestEntity1("str1", 1);
em.persist(entity);
em.getTransaction().commit();
id = entity.getId();
// Revision 2 - both properties (str1 and long1) should be marked as modified.
em.getTransaction().begin();
entity = em.find(BasicTestEntity1.class, entity.getId());
entity.setStr1("str2");
entity = em.merge(entity);
em.flush();
entity.setLong1(2);
entity = em.merge(entity);
em.flush();
em.getTransaction().commit();
em.close();
}
use of org.hibernate.envers.test.integration.basic.BasicTestEntity1 in project hibernate-orm by hibernate.
the class ModifiedFlagSuffix method addNewEntity.
private Integer addNewEntity(String str, long lng) {
EntityManager em = getEntityManager();
em.getTransaction().begin();
BasicTestEntity1 bte1 = new BasicTestEntity1(str, lng);
em.persist(bte1);
em.getTransaction().commit();
return bte1.getId();
}
use of org.hibernate.envers.test.integration.basic.BasicTestEntity1 in project hibernate-orm by hibernate.
the class HasChangedNullProperties method addNewEntity.
private Integer addNewEntity(String str, long lng) {
EntityManager em = getEntityManager();
em.getTransaction().begin();
BasicTestEntity1 bte1 = new BasicTestEntity1(str, lng);
em.persist(bte1);
em.getTransaction().commit();
return bte1.getId();
}
use of org.hibernate.envers.test.integration.basic.BasicTestEntity1 in project hibernate-orm by hibernate.
the class ModifiedFlagSuffix method testHasChanged.
@Test
public void testHasChanged() throws Exception {
List list = queryForPropertyHasChangedWithDeleted(BasicTestEntity1.class, id1, "str1");
assertEquals(1, list.size());
assertEquals(makeList(1), extractRevisionNumbers(list));
list = queryForPropertyHasChangedWithDeleted(BasicTestEntity1.class, id1, "long1");
assertEquals(1, list.size());
assertEquals(makeList(1), extractRevisionNumbers(list));
list = getAuditReader().createQuery().forRevisionsOfEntity(BasicTestEntity1.class, false, true).add(AuditEntity.property("str1").hasChanged()).add(AuditEntity.property("long1").hasChanged()).getResultList();
assertEquals(1, list.size());
assertEquals(makeList(1), extractRevisionNumbers(list));
}
Aggregations