use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class VersionsJoinTableNaming method initData.
@Test
@Priority(10)
public void initData() {
VersionsJoinTableTestEntity uni1 = new VersionsJoinTableTestEntity(1, "data1");
StrTestEntity str1 = new StrTestEntity("str1");
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
uni1.setCollection(new HashSet<StrTestEntity>());
em.persist(uni1);
em.persist(str1);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
uni1 = em.find(VersionsJoinTableTestEntity.class, uni1.getId());
str1 = em.find(StrTestEntity.class, str1.getId());
uni1.getCollection().add(str1);
em.getTransaction().commit();
//
uni1_id = uni1.getId();
str1_id = str1.getId();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class HasChangedOneToManyInComponent method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrTestEntity ste1 = new StrTestEntity();
ste1.setStr("str1");
StrTestEntity ste2 = new StrTestEntity();
ste2.setStr("str2");
em.persist(ste1);
em.persist(ste2);
em.getTransaction().commit();
// Revision 2
em = getEntityManager();
em.getTransaction().begin();
OneToManyComponentTestEntity otmcte1 = new OneToManyComponentTestEntity(new OneToManyComponent("data1"));
otmcte1.getComp1().getEntities().add(ste1);
em.persist(otmcte1);
em.getTransaction().commit();
// Revision 3
em = getEntityManager();
em.getTransaction().begin();
otmcte1 = em.find(OneToManyComponentTestEntity.class, otmcte1.getId());
otmcte1.getComp1().getEntities().add(ste2);
em.getTransaction().commit();
otmcte_id1 = otmcte1.getId();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class DefaultTrackingEntitiesTest method testTrackAddedEntities.
@Test
public void testTrackAddedEntities() {
StrTestEntity ste = new StrTestEntity("x", steId);
StrIntTestEntity site = new StrIntTestEntity("y", 1, siteId);
assert TestTools.checkCollection(getCrossTypeRevisionChangesReader().findEntities(1), ste, site);
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class TrackingEntitiesMultipleChangesTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 - Adding two entities
em.getTransaction().begin();
StrTestEntity ste1 = new StrTestEntity("x");
StrTestEntity ste2 = new StrTestEntity("y");
em.persist(ste1);
em.persist(ste2);
steId1 = ste1.getId();
steId2 = ste2.getId();
em.getTransaction().commit();
// Revision 2 - Adding first and removing second entity
em.getTransaction().begin();
ste1 = em.find(StrTestEntity.class, steId1);
ste2 = em.find(StrTestEntity.class, steId2);
ste1.setStr("z");
em.remove(ste2);
em.getTransaction().commit();
// Revision 3 - Modifying and removing the same entity.
em.getTransaction().begin();
ste1 = em.find(StrTestEntity.class, steId1);
ste1.setStr("a");
em.merge(ste1);
em.remove(ste1);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class TrackingEntitiesMultipleChangesTest method testTrackUpdateAndRemoveTheSameEntity.
@Test
public void testTrackUpdateAndRemoveTheSameEntity() {
StrTestEntity ste1 = new StrTestEntity(null, steId1);
Assert.assertEquals(TestTools.makeSet(ste1), new HashSet<Object>(getCrossTypeRevisionChangesReader().findEntities(3)));
}
Aggregations