@@ -68,11 +68,11 @@ public void closeOrmFactory() {
6868 public void testORMWithStageSession (TestContext context ) {
6969 final Flour almond = new Flour ( 1 , "Almond" , "made from ground almonds." , "Gluten free" );
7070
71- Session session = ormFactory .openSession ();
72- session .beginTransaction ();
73- session .persist ( almond );
74- session .getTransaction ().commit ();
75- session . close ();
71+ try ( Session session = ormFactory .openSession ()) {
72+ session .beginTransaction ();
73+ session .persist ( almond );
74+ session .getTransaction ().commit ();
75+ }
7676
7777 // Check database with Stage session and verify 'almond' flour exists
7878 test ( context , openSession ()
@@ -85,11 +85,11 @@ public void testORMWithStageSession(TestContext context) {
8585 public void testORMWitMutinySession (TestContext context ) {
8686 final Flour rose = new Flour ( 2 , "Rose" , "made from ground rose pedals." , "Full fragrance" );
8787
88- Session ormSession = ormFactory .openSession ();
89- ormSession .beginTransaction ();
90- ormSession .persist ( rose );
91- ormSession .getTransaction ().commit ();
92- ormSession . close ();
88+ try ( Session ormSession = ormFactory .openSession ()) {
89+ ormSession .beginTransaction ();
90+ ormSession .persist ( rose );
91+ ormSession .getTransaction ().commit ();
92+ }
9393
9494 // Check database with Mutiny session and verify 'rose' flour exists
9595 test ( context , openMutinySession ()
0 commit comments