File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -2444,10 +2444,10 @@ the `TransactionOperator` resembles the next example:
2444
2444
}
2445
2445
2446
2446
public Mono<Object> someServiceMethod() {
2447
-
2447
+
2448
2448
// the code in this method runs in a transactional context
2449
-
2450
- Mono<Object> update = updateOperation1();
2449
+
2450
+ Mono<Object> update = updateOperation1();
2451
2451
2452
2452
return update.then(resultOfUpdateOperation2).as(transactionalOperator::transactional);
2453
2453
}
@@ -8212,11 +8212,17 @@ that uses the `@PersistenceUnit` annotation:
8212
8212
}
8213
8213
8214
8214
public Collection loadProductsByCategory(String category) {
8215
- try (EntityManager em = this.emf.createEntityManager()) {
8215
+ EntityManager em = this.emf.createEntityManager();
8216
+ try {
8216
8217
Query query = em.createQuery("from Product as p where p.category = ?1");
8217
8218
query.setParameter(1, category);
8218
8219
return query.getResultList();
8219
8220
}
8221
+ finally {
8222
+ if (em != null) {
8223
+ em.close();
8224
+ }
8225
+ }
8220
8226
}
8221
8227
}
8222
8228
----
You can’t perform that action at this time.
0 commit comments