From fc7547a354b2e4bc1d0ac4b5b27d4227cb6e2caa Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Fri, 24 Jul 2020 14:32:06 +0200 Subject: [PATCH] DATAJPA-1761 - Readds call to save for consistency with other Spring Data modules. --- src/main/asciidoc/jpa.adoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/asciidoc/jpa.adoc b/src/main/asciidoc/jpa.adoc index c7f20cb4c..f51dc2865 100644 --- a/src/main/asciidoc/jpa.adoc +++ b/src/main/asciidoc/jpa.adoc @@ -860,11 +860,14 @@ class UserManagementImpl implements UserManagement { for (User user : userRepository.findAll()) { user.addRole(role); - // note that no call to "save" is necessary since the entities are attached to the EntityManager + userRepository.save(user); } } ---- -This example causes call to `addRoleToAllUsers(…)` to run inside a transaction (participating in an existing one or creating a new one if none are already running). The transaction configuration at the repositories is then neglected, as the outer transaction configuration determines the actual one used. Note that you must activate `` or use `@EnableTransactionManagement` explicitly to get annotation-based configuration of facades to work. This example assumes you use component scanning. +This example causes call to `addRoleToAllUsers(…)` to run inside a transaction (participating in an existing one or creating a new one if none are already running). The transaction configuration at the repositories is then neglected, as the outer transaction configuration determines the actual one used. Note that you must activate `` or use `@EnableTransactionManagement` explicitly to get annotation-based configuration of facades to work. +This example assumes you use component scanning. + +Note that the call to `save` is not strictly necessary from a JPA point of view, but should still be there in order to stay consistent to the repository abstraction offered by Spring Data. ==== [[transactional-query-methods]]