HHH-9995 - Finish pgsql database profile - rollback transaction on error in TestLazyBasicFieldAccessExecutable

This commit is contained in:
Martin Simka 2015-08-18 17:27:13 +02:00 committed by Andrea Boriero
parent fe1b141f79
commit ca0eee08a0
1 changed files with 11 additions and 5 deletions

View File

@ -16,7 +16,7 @@ public class TestLazyBasicFieldAccessExecutable extends AbstractExecutable {
return new String[] {"org/hibernate/test/instrument/domain/Documents.hbm.xml"}; return new String[] {"org/hibernate/test/instrument/domain/Documents.hbm.xml"};
} }
public void execute() { public void execute() throws Exception {
Session s = getFactory().openSession(); Session s = getFactory().openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Owner o = new Owner(); Owner o = new Owner();
@ -51,10 +51,16 @@ public class TestLazyBasicFieldAccessExecutable extends AbstractExecutable {
doc.setName( "Doc Name 1" ); doc.setName( "Doc Name 1" );
doc.setSummary( "v" ); doc.setSummary( "v" );
Document docManaged = (Document) s.merge( doc ); Document docManaged = (Document) s.merge( doc );
Assert.assertEquals( "v", docManaged.getSummary() ); try {
Assert.assertTrue( Hibernate.isPropertyInitialized( docManaged, "summary" ) ); Assert.assertEquals("v", docManaged.getSummary());
s.getTransaction().commit(); Assert.assertTrue( Hibernate.isPropertyInitialized( docManaged, "summary" ) );
s.close(); s.getTransaction().commit();
} catch (Exception e) {
s.getTransaction().rollback();
throw e;
} finally {
s.close();
}
s = getFactory().openSession(); s = getFactory().openSession();
s.getTransaction().begin(); s.getTransaction().begin();