use of org.hibernate.IrrelevantEntity in project hibernate-orm by hibernate.
the class LegacyPostCommitListenerTest method testPostCommitDeleteListenerRollback.
@Test
@TestForIssue(jiraKey = "HHH-1582")
public void testPostCommitDeleteListenerRollback() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName("Irrelevant");
session.save(irrelevantEntity);
session.flush();
transaction.commit();
session.close();
session = openSession();
transaction = session.beginTransaction();
session.delete(irrelevantEntity);
session.flush();
transaction.rollback();
session.close();
//the legacy implementation fires the listener on failure as well
Assert.assertEquals(1, ((LegacyPostCommitDeleteEventListener) postCommitDeleteEventListener).fired);
}
use of org.hibernate.IrrelevantEntity in project hibernate-orm by hibernate.
the class LegacyPostCommitListenerTest method testPostCommitInsertListenerSuccess.
@Test
@TestForIssue(jiraKey = "HHH-1582")
public void testPostCommitInsertListenerSuccess() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName("Irrelevant");
session.save(irrelevantEntity);
session.flush();
transaction.commit();
session.close();
Assert.assertEquals(1, ((LegacyPostCommitInsertEventListener) postCommitInsertEventListener).fired);
}
use of org.hibernate.IrrelevantEntity in project hibernate-orm by hibernate.
the class LegacyPostCommitListenerTest method testPostCommitUpdateListenerRollback.
@Test
@TestForIssue(jiraKey = "HHH-1582")
public void testPostCommitUpdateListenerRollback() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName("Irrelevant");
session.save(irrelevantEntity);
session.flush();
transaction.commit();
session.close();
session = openSession();
transaction = session.beginTransaction();
irrelevantEntity.setName("Irrelevant 2");
session.update(irrelevantEntity);
session.flush();
transaction.rollback();
session.close();
//the legacy implementation fires the listener on failure as well
Assert.assertEquals(1, ((LegacyPostCommitUpdateEventListener) postCommitUpdateEventListener).fired);
}
use of org.hibernate.IrrelevantEntity in project hibernate-orm by hibernate.
the class PostCommitListenerTest method testPostCommitUpdateListenerSuccess.
@Test
@TestForIssue(jiraKey = "HHH-1582")
public void testPostCommitUpdateListenerSuccess() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName("Irrelevant");
session.save(irrelevantEntity);
session.flush();
transaction.commit();
session = openSession();
transaction = session.beginTransaction();
irrelevantEntity.setName("Irrelevant 2");
session.update(irrelevantEntity);
session.flush();
transaction.commit();
session.close();
Assert.assertEquals(1, ((TestPostCommitUpdateEventListener) postCommitUpdateEventListener).sucess);
Assert.assertEquals(0, ((TestPostCommitUpdateEventListener) postCommitUpdateEventListener).failed);
}
Aggregations