use of org.hibernate.envers.test.entities.ids.EmbIdTestEntity in project hibernate-orm by hibernate.
the class SimpleQuery method testEmbeddedIdPropertyRestriction.
@Test
@TestForIssue(jiraKey = "HHH-8567")
public void testEmbeddedIdPropertyRestriction() {
EmbIdTestEntity ver2 = (EmbIdTestEntity) getAuditReader().createQuery().forEntitiesAtRevision(EmbIdTestEntity.class, 2).add(AuditEntity.property("id.x").eq(embId1.getX())).add(AuditEntity.property("id.y").eq(embId1.getY())).getSingleResult();
Assert.assertEquals(new EmbIdTestEntity(embId1, "something"), ver2);
}
use of org.hibernate.envers.test.entities.ids.EmbIdTestEntity in project hibernate-orm by hibernate.
the class SimpleQuery method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrIntTestEntity site1 = new StrIntTestEntity("a", 10);
StrIntTestEntity site2 = new StrIntTestEntity("a", 10);
StrIntTestEntity site3 = new StrIntTestEntity("b", 5);
em.persist(site1);
em.persist(site2);
em.persist(site3);
id1 = site1.getId();
id2 = site2.getId();
id3 = site3.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
mulId1 = new MulId(1, 2);
em.persist(new MulIdTestEntity(mulId1.getId1(), mulId1.getId2(), "data"));
embId1 = new EmbId(3, 4);
em.persist(new EmbIdTestEntity(embId1, "something"));
site1 = em.find(StrIntTestEntity.class, id1);
site2 = em.find(StrIntTestEntity.class, id2);
site1.setStr1("aBc");
site2.setNumber(20);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
site3 = em.find(StrIntTestEntity.class, id3);
site3.setStr1("a");
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
site1 = em.find(StrIntTestEntity.class, id1);
em.remove(site1);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.EmbIdTestEntity in project hibernate-orm by hibernate.
the class BasicDetachedSetWithEmbId method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
str1_id = new EmbId(1, 2);
str2_id = new EmbId(3, 4);
coll1_id = new EmbId(5, 6);
EmbIdTestEntity str1 = new EmbIdTestEntity(str1_id, "str1");
EmbIdTestEntity str2 = new EmbIdTestEntity(str2_id, "str2");
SetRefCollEntityEmbId coll1 = new SetRefCollEntityEmbId(coll1_id, "coll1");
// Revision 1
em.getTransaction().begin();
em.persist(str1);
em.persist(str2);
coll1.setCollection(new HashSet<EmbIdTestEntity>());
coll1.getCollection().add(str1);
em.persist(coll1);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
str2 = em.find(EmbIdTestEntity.class, str2.getId());
coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
coll1.getCollection().add(str2);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
str1 = em.find(EmbIdTestEntity.class, str1.getId());
coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
coll1.getCollection().remove(str1);
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
coll1.getCollection().clear();
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.EmbIdTestEntity in project hibernate-orm by hibernate.
the class UnidirectionalMulIdWithNulls method initData.
@Test
@Priority(10)
public void initData() {
ei = new EmbId(1, 2);
EntityManager em = getEntityManager();
// Revision 1
EmbIdTestEntity eite = new EmbIdTestEntity(ei, "data");
UniRefIngMulIdEntity notNullRef = new UniRefIngMulIdEntity(1, "data 1", eite);
UniRefIngMulIdEntity nullRef = new UniRefIngMulIdEntity(2, "data 2", null);
em.getTransaction().begin();
em.persist(eite);
em.persist(notNullRef);
em.persist(nullRef);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.EmbIdTestEntity in project hibernate-orm by hibernate.
the class CompositeIds method testHistoryOfId2.
@Test
public void testHistoryOfId2() {
EmbIdTestEntity ver1 = new EmbIdTestEntity(id2, "y");
EmbIdTestEntity ver2 = new EmbIdTestEntity(id2, "y2");
EmbIdTestEntity ver3 = new EmbIdTestEntity(id2, "y3");
assert getAuditReader().find(EmbIdTestEntity.class, id2, 1) == null;
assert getAuditReader().find(EmbIdTestEntity.class, id2, 2).equals(ver1);
assert getAuditReader().find(EmbIdTestEntity.class, id2, 3).equals(ver2);
assert getAuditReader().find(EmbIdTestEntity.class, id2, 4).equals(ver3);
assert getAuditReader().find(EmbIdTestEntity.class, id2, 5) == null;
}
Aggregations