diff --git a/src/docs/asciidoc/data-access.adoc b/src/docs/asciidoc/data-access.adoc index 404df7690ab..a08719343ba 100644 --- a/src/docs/asciidoc/data-access.adoc +++ b/src/docs/asciidoc/data-access.adoc @@ -2444,10 +2444,10 @@ the `TransactionOperator` resembles the next example: } public Mono someServiceMethod() { - + // the code in this method runs in a transactional context - - Mono update = updateOperation1(); + + Mono update = updateOperation1(); return update.then(resultOfUpdateOperation2).as(transactionalOperator::transactional); } @@ -8212,11 +8212,17 @@ that uses the `@PersistenceUnit` annotation: } public Collection loadProductsByCategory(String category) { - try (EntityManager em = this.emf.createEntityManager()) { + EntityManager em = this.emf.createEntityManager(); + try { Query query = em.createQuery("from Product as p where p.category = ?1"); query.setParameter(1, category); return query.getResultList(); } + finally { + if (em != null) { + em.close(); + } + } } } ----