use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class StringList method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
StringListEntity sle1 = new StringListEntity();
StringListEntity sle2 = new StringListEntity();
// Revision 1 (sle1: initialy empty, sle2: initialy 2 elements)
em.getTransaction().begin();
sle2.getStrings().add("sle2_string1");
sle2.getStrings().add("sle2_string2");
em.persist(sle1);
em.persist(sle2);
em.getTransaction().commit();
// Revision 2 (sle1: adding 2 elements, sle2: adding an existing element)
em.getTransaction().begin();
sle1 = em.find(StringListEntity.class, sle1.getId());
sle2 = em.find(StringListEntity.class, sle2.getId());
sle1.getStrings().add("sle1_string1");
sle1.getStrings().add("sle1_string2");
sle2.getStrings().add("sle2_string1");
em.getTransaction().commit();
// Revision 3 (sle1: replacing an element at index 0, sle2: removing an element at index 0)
em.getTransaction().begin();
sle1 = em.find(StringListEntity.class, sle1.getId());
sle2 = em.find(StringListEntity.class, sle2.getId());
sle1.getStrings().set(0, "sle1_string3");
sle2.getStrings().remove(0);
em.getTransaction().commit();
//
sle1_id = sle1.getId();
sle2_id = sle2.getId();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class StringSet method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
StringSetEntity sse1 = new StringSetEntity();
StringSetEntity sse2 = new StringSetEntity();
// Revision 1 (sse1: initialy empty, sse2: initialy 2 elements)
em.getTransaction().begin();
sse2.getStrings().add("sse2_string1");
sse2.getStrings().add("sse2_string2");
em.persist(sse1);
em.persist(sse2);
em.getTransaction().commit();
// Revision 2 (sse1: adding 2 elements, sse2: adding an existing element)
em.getTransaction().begin();
sse1 = em.find(StringSetEntity.class, sse1.getId());
sse2 = em.find(StringSetEntity.class, sse2.getId());
sse1.getStrings().add("sse1_string1");
sse1.getStrings().add("sse1_string2");
sse2.getStrings().add("sse2_string1");
em.getTransaction().commit();
// Revision 3 (sse1: removing a non-existing element, sse2: removing one element)
em.getTransaction().begin();
sse1 = em.find(StringSetEntity.class, sse1.getId());
sse2 = em.find(StringSetEntity.class, sse2.getId());
sse1.getStrings().remove("sse1_string3");
sse2.getStrings().remove("sse2_string1");
em.getTransaction().commit();
//
sse1_id = sse1.getId();
sse2_id = sse2.getId();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class BasicEmbeddableCollection method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 - empty element collection
em.getTransaction().begin();
DarkCharacter darkCharacter = new DarkCharacter(1, 1);
em.persist(darkCharacter);
em.getTransaction().commit();
id = darkCharacter.getId();
// Revision 2 - adding collection element
em.getTransaction().begin();
darkCharacter = em.find(DarkCharacter.class, darkCharacter.getId());
darkCharacter.getNames().add(new Name("Action", "Hank"));
darkCharacter = em.merge(darkCharacter);
em.getTransaction().commit();
// Revision 3 - adding another collection element
em.getTransaction().begin();
darkCharacter = em.find(DarkCharacter.class, darkCharacter.getId());
darkCharacter.getNames().add(new Name("Green", "Lantern"));
darkCharacter = em.merge(darkCharacter);
em.getTransaction().commit();
// Revision 4 - removing single collection element
em.getTransaction().begin();
darkCharacter = em.find(DarkCharacter.class, darkCharacter.getId());
darkCharacter.getNames().remove(new Name("Action", "Hank"));
darkCharacter = em.merge(darkCharacter);
em.getTransaction().commit();
// Revision 5 - removing all collection elements
em.getTransaction().begin();
darkCharacter = em.find(DarkCharacter.class, darkCharacter.getId());
darkCharacter.getNames().clear();
darkCharacter = em.merge(darkCharacter);
em.getTransaction().commit();
em.close();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class AbstractCollectionChangeTest method initData.
@Test
@Priority(10)
public void initData() {
Session session = openSession();
// Rev 1
session.getTransaction().begin();
Person p = new Person();
Name n = new Name();
n.setName("name1");
p.getNames().add(n);
session.saveOrUpdate(p);
session.getTransaction().commit();
// Rev 2
session.getTransaction().begin();
n.setName("Changed name");
session.saveOrUpdate(p);
session.getTransaction().commit();
// Rev 3
session.getTransaction().begin();
Name n2 = new Name();
n2.setName("name2");
p.getNames().add(n2);
session.getTransaction().commit();
personId = p.getId();
session.close();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class PropertiesGroupTest method initData.
@Test
@Priority(10)
public void initData() {
uniquePropsAudit = metadata().getEntityBinding("org.hibernate.envers.test.entities.components.UniquePropsEntity_AUD");
uniquePropsNotAuditedAudit = metadata().getEntityBinding("org.hibernate.envers.test.entities.components.UniquePropsNotAuditedEntity_AUD");
// Revision 1
Session session = openSession();
session.getTransaction().begin();
UniquePropsEntity ent = new UniquePropsEntity();
ent.setData1("data1");
ent.setData2("data2");
session.persist(ent);
session.getTransaction().commit();
entityRev1 = new UniquePropsEntity(ent.getId(), ent.getData1(), ent.getData2());
// Revision 2
session.getTransaction().begin();
UniquePropsNotAuditedEntity entNotAud = new UniquePropsNotAuditedEntity();
entNotAud.setData1("data3");
entNotAud.setData2("data4");
session.persist(entNotAud);
session.getTransaction().commit();
entityNotAuditedRev2 = new UniquePropsNotAuditedEntity(entNotAud.getId(), entNotAud.getData1(), null);
}
Aggregations