HHH-9995 - Finish pgsql database profile - rollback transaction on error in TestLazyBasicFieldAccessExecutable
This commit is contained in:
parent
fe1b141f79
commit
ca0eee08a0
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue