use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class JoinColumnNaturalIdTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getOrCreateEntityManager();
try {
// Revision 1
em.getTransaction().begin();
Customer customer = new Customer();
customer.setCustomerNumber("1234567");
customer.setName("ACME");
em.persist(customer);
em.getTransaction().commit();
customerId = customer.getId();
// Revision 2
em.getTransaction().begin();
Device device = new Device();
device.setCustomer(customer);
Account account = new Account();
account.setCustomer(customer);
em.persist(account);
em.persist(device);
em.getTransaction().commit();
accountId = account.getId();
deviceId = device.getId();
// Revision 3
em.getTransaction().begin();
em.remove(account);
em.getTransaction().commit();
} finally {
em.close();
}
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class NotInsertable method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();
NotInsertableTestEntity dte = new NotInsertableTestEntity("data1");
em.persist(dte);
id1 = dte.getId();
em.getTransaction().commit();
em.getTransaction().begin();
dte = em.find(NotInsertableTestEntity.class, id1);
dte.setData("data2");
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class ManyToOneNotInsertable method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
mto_id1 = 1;
type_id1 = 2;
type_id2 = 3;
// Rev 1
// Preparing the types
em.getTransaction().begin();
NotInsertableEntityType type1 = new NotInsertableEntityType(type_id1, "type1");
NotInsertableEntityType type2 = new NotInsertableEntityType(type_id2, "type2");
em.persist(type1);
em.persist(type2);
em.getTransaction().commit();
// Rev 2
em.getTransaction().begin();
ManyToOneNotInsertableEntity master = new ManyToOneNotInsertableEntity(mto_id1, type_id1, type1);
em.persist(master);
em.getTransaction().commit();
// Rev 2
em.getTransaction().begin();
master = em.find(ManyToOneNotInsertableEntity.class, mto_id1);
master.setNumber(type_id2);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class PropertyNotUpdatableTest method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
PropertyNotUpdatableEntity entity = new PropertyNotUpdatableEntity("data", "constant data 1", "constant data 2");
em.persist(entity);
em.getTransaction().commit();
id = entity.getId();
// Revision 2
em.getTransaction().begin();
entity = em.find(PropertyNotUpdatableEntity.class, entity.getId());
entity.setData("modified data");
entity.setConstantData1(null);
em.merge(entity);
em.getTransaction().commit();
em.close();
// Re-opening entity manager to re-initialize non-updatable fields
em = getEntityManager();
// with database values. Otherwise PostUpdateEvent#getOldState() returns previous
// memory state. This can be achieved using EntityManager#refresh(Object) method as well.
// Revision 3
em.getTransaction().begin();
entity = em.find(PropertyNotUpdatableEntity.class, entity.getId());
entity.setData("another modified data");
entity.setConstantData2("invalid data");
em.merge(entity);
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
em.refresh(entity);
em.remove(entity);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class BidirectionalManyToOneOptionalTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager entityManager = getEntityManager();
try {
// Revision 1
entityManager.getTransaction().begin();
// store refing with null refed entity
BiRefingOptionalEntity refingWithNoRefed = new BiRefingOptionalEntity();
refingWithNoRefed.setReference(null);
entityManager.persist(refingWithNoRefed);
// store refing with non-null refed entity
BiRefingOptionalEntity refing = new BiRefingOptionalEntity();
BiRefedOptionalEntity refed = new BiRefedOptionalEntity();
refed.getReferences().add(refing);
refing.setReference(refed);
entityManager.persist(refing);
entityManager.persist(refed);
entityManager.getTransaction().commit();
this.refingId = refing.getId();
this.refedId = refed.getId();
this.refingWithNoRefedId = refingWithNoRefed.getId();
} finally {
entityManager.close();
}
}
Aggregations