use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class HasChangedEnumSet method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
EnumSetEntity sse1 = new EnumSetEntity();
// Revision 1 (sse1: initialy 1 element)
em.getTransaction().begin();
sse1.getEnums1().add(E1.X);
sse1.getEnums2().add(E2.A);
em.persist(sse1);
em.getTransaction().commit();
// Revision 2 (sse1: adding 1 element/removing a non-existing element)
em.getTransaction().begin();
sse1 = em.find(EnumSetEntity.class, sse1.getId());
sse1.getEnums1().add(E1.Y);
sse1.getEnums2().remove(E2.B);
em.getTransaction().commit();
// Revision 3 (sse1: removing 1 element/adding an exisiting element)
em.getTransaction().begin();
sse1 = em.find(EnumSetEntity.class, sse1.getId());
sse1.getEnums1().remove(E1.X);
sse1.getEnums2().add(E2.A);
em.getTransaction().commit();
//
sse1_id = sse1.getId();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class HasChangedForDefaultNotUsing method initData.
@Test
@Priority(10)
public void initData() {
PartialModifiedFlagsEntity entity = new PartialModifiedFlagsEntity(entityId);
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
em.persist(entity);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
entity.setData("data1");
entity = em.merge(entity);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
entity.setComp1(new Component1("str1", "str2"));
entity = em.merge(entity);
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
entity.setComp2(new Component2("str1", "str2"));
entity = em.merge(entity);
em.getTransaction().commit();
// Revision 5
em.getTransaction().begin();
WithModifiedFlagReferencingEntity withModifiedFlagReferencingEntity = new WithModifiedFlagReferencingEntity(refEntityId, "first");
withModifiedFlagReferencingEntity.setReference(entity);
em.persist(withModifiedFlagReferencingEntity);
em.getTransaction().commit();
// Revision 6
em.getTransaction().begin();
withModifiedFlagReferencingEntity = em.find(WithModifiedFlagReferencingEntity.class, refEntityId);
withModifiedFlagReferencingEntity.setReference(null);
withModifiedFlagReferencingEntity.setSecondReference(entity);
em.merge(withModifiedFlagReferencingEntity);
em.getTransaction().commit();
// Revision 7
em.getTransaction().begin();
entity.getStringSet().add("firstElement");
entity.getStringSet().add("secondElement");
entity = em.merge(entity);
em.getTransaction().commit();
// Revision 8
em.getTransaction().begin();
entity.getStringSet().remove("secondElement");
entity.getStringMap().put("someKey", "someValue");
entity = em.merge(entity);
em.getTransaction().commit();
// Revision 9 - main entity doesn't change
em.getTransaction().begin();
StrTestEntity strTestEntity = new StrTestEntity("first");
em.persist(strTestEntity);
em.getTransaction().commit();
// Revision 10
em.getTransaction().begin();
entity.getEntitiesSet().add(strTestEntity);
entity = em.merge(entity);
em.getTransaction().commit();
// Revision 11
em.getTransaction().begin();
entity.getEntitiesSet().remove(strTestEntity);
entity.getEntitiesMap().put("someKey", strTestEntity);
em.merge(entity);
em.getTransaction().commit();
// Revision 12 - main entity doesn't change
em.getTransaction().begin();
strTestEntity.setStr("second");
em.merge(strTestEntity);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class VersionsJoinTableRangeComponentNamingTest method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
// create an instance of the test entity
VersionsJoinTableRangeComponentTestEntity vjrcte = new VersionsJoinTableRangeComponentTestEntity();
em.persist(vjrcte);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
vjrcte = em.find(VersionsJoinTableRangeComponentTestEntity.class, vjrcte.getId());
// create a component containing a list of
// VersionsJoinTableRangeTestEntity-instances
VersionsJoinTableRangeTestEntity vjtrte = new VersionsJoinTableRangeTestEntity();
vjtrte.setGenericValue("generic1");
vjtrte.setValue("value1");
// and add it to the test entity
vjrcte.getComponent1().getRange().add(vjtrte);
// create a second component containing a list of
// VersionsJoinTableRangeTestAlternateEntity-instances
VersionsJoinTableRangeTestAlternateEntity vjtrtae1 = new VersionsJoinTableRangeTestAlternateEntity();
vjtrtae1.setGenericValue("generic2");
vjtrtae1.setAlternateValue("alternateValue2");
// and add it to the test entity
vjrcte.getComponent2().getRange().add(vjtrtae1);
// create a third component, and add it to the test entity
Component1 simpleComponent = new Component1("string1", "string2");
vjrcte.setComponent3(simpleComponent);
em.persist(vjtrte);
em.persist(vjtrtae1);
em.persist(vjrcte);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
vjrcte = em.find(VersionsJoinTableRangeComponentTestEntity.class, vjrcte.getId());
vjtrte = em.find(VersionsJoinTableRangeTestEntity.class, vjtrte.getId());
vjtrtae1 = em.find(VersionsJoinTableRangeTestAlternateEntity.class, vjtrtae1.getId());
assert vjrcte != null;
assert vjtrte != null;
assert vjtrtae1 != null;
List<VersionsJoinTableRangeTestEntity> ent1List = vjrcte.getComponent1().getRange();
assert ent1List.size() == 1;
assert vjtrte.equals(ent1List.get(0));
List<VersionsJoinTableRangeTestAlternateEntity> ent2List = vjrcte.getComponent2().getRange();
assert ent2List.size() == 1;
assert vjtrtae1.equals(ent2List.get(0));
em.getTransaction().commit();
vjrcte_id = vjrcte.getId();
vjtrte_id = vjtrte.getId();
vjtrtae_id1 = vjtrtae1.getId();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class JoinMulIdNaming method initData.
@Test
@Priority(10)
public void initData() {
ed_id1 = new MulIdNaming(10, 20);
ed_id2 = new MulIdNaming(11, 21);
ing_id1 = new MulIdNaming(12, 22);
JoinMulIdNamingRefEdEntity ed1 = new JoinMulIdNamingRefEdEntity(ed_id1, "data1");
JoinMulIdNamingRefEdEntity ed2 = new JoinMulIdNamingRefEdEntity(ed_id2, "data2");
JoinMulIdNamingRefIngEntity ing1 = new JoinMulIdNamingRefIngEntity(ing_id1, "x", ed1);
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
em.persist(ed1);
em.persist(ed2);
em.persist(ing1);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
ed2 = em.find(JoinMulIdNamingRefEdEntity.class, ed_id2);
ing1 = em.find(JoinMulIdNamingRefIngEntity.class, ing_id1);
ing1.setData("y");
ing1.setReference(ed2);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class QuotedFieldsTest method initData.
@Test
@Priority(10)
public void initData() {
QuotedFieldsEntity qfe1 = new QuotedFieldsEntity("data1", 1);
QuotedFieldsEntity qfe2 = new QuotedFieldsEntity("data2", 2);
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
em.persist(qfe1);
em.persist(qfe2);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
qfe1 = em.find(QuotedFieldsEntity.class, qfe1.getId());
qfe1.setData1("data1 changed");
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
qfe2 = em.find(QuotedFieldsEntity.class, qfe2.getId());
qfe2.setData2(3);
em.getTransaction().commit();
qfeId1 = qfe1.getId();
qfeId2 = qfe2.getId();
}
Aggregations