use of org.hibernate.IrrelevantEntity in project hibernate-orm by hibernate.
the class PostCommitListenerTest 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, ((TestPostCommitInsertEventListener) postCommitInsertEventListener).success);
Assert.assertEquals(0, ((TestPostCommitInsertEventListener) postCommitInsertEventListener).failed);
}
use of org.hibernate.IrrelevantEntity in project hibernate-orm by hibernate.
the class PostCommitListenerTest method testPostCommitInsertListenerRollback.
@Test
@TestForIssue(jiraKey = "HHH-1582")
public void testPostCommitInsertListenerRollback() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName("Irrelevant");
session.save(irrelevantEntity);
session.flush();
transaction.rollback();
session.close();
Assert.assertEquals(0, ((TestPostCommitInsertEventListener) postCommitInsertEventListener).success);
Assert.assertEquals(1, ((TestPostCommitInsertEventListener) postCommitInsertEventListener).failed);
}
use of org.hibernate.IrrelevantEntity in project hibernate-orm by hibernate.
the class PostCommitListenerTest method testPostCommitDeleteListenerSuccess.
@Test
@TestForIssue(jiraKey = "HHH-1582")
public void testPostCommitDeleteListenerSuccess() {
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.commit();
session.close();
Assert.assertEquals(1, ((TestPostCommitDeleteEventListener) postCommitDeleteEventListener).success);
Assert.assertEquals(0, ((TestPostCommitDeleteEventListener) postCommitDeleteEventListener).failed);
}
use of org.hibernate.IrrelevantEntity in project hibernate-orm by hibernate.
the class LegacyPostCommitListenerTest method testPostCommitDeleteListenerSuccess.
@Test
@TestForIssue(jiraKey = "HHH-1582")
public void testPostCommitDeleteListenerSuccess() {
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.commit();
session.close();
Assert.assertEquals(1, ((LegacyPostCommitDeleteEventListener) postCommitDeleteEventListener).fired);
}
use of org.hibernate.IrrelevantEntity in project hibernate-orm by hibernate.
the class LegacyPostCommitListenerTest method testPostCommitInsertListenerRollback.
@Test
@TestForIssue(jiraKey = "HHH-1582")
public void testPostCommitInsertListenerRollback() {
Session session = openSession();
Transaction transaction = session.beginTransaction();
IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName("Irrelevant");
session.save(irrelevantEntity);
session.flush();
transaction.rollback();
session.close();
//the legacy implementation fires the listener on failure as well
Assert.assertEquals(1, ((LegacyPostCommitInsertEventListener) postCommitInsertEventListener).fired);
}
Aggregations