@@ -68,11 +68,11 @@ public void closeOrmFactory() {
68
68
public void testORMWithStageSession (TestContext context ) {
69
69
final Flour almond = new Flour ( 1 , "Almond" , "made from ground almonds." , "Gluten free" );
70
70
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
+ }
76
76
77
77
// Check database with Stage session and verify 'almond' flour exists
78
78
test ( context , openSession ()
@@ -85,11 +85,11 @@ public void testORMWithStageSession(TestContext context) {
85
85
public void testORMWitMutinySession (TestContext context ) {
86
86
final Flour rose = new Flour ( 2 , "Rose" , "made from ground rose pedals." , "Full fragrance" );
87
87
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
+ }
93
93
94
94
// Check database with Mutiny session and verify 'rose' flour exists
95
95
test ( context , openMutinySession ()
0 commit comments