From 5d34f0a00db03826eaf3407ec11e9dad1d77fb19 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Thu, 4 May 2017 23:03:22 +0200 Subject: [PATCH] #297 - Tweaked persistence context handling in security tests. The modifying query now clears the EntityManager so that the changes are really flushed to the database. This is necessary as Boot 2.0 flips the default for Hibernate's new identifier mappings which causes entities less aggressively being flushed and the previously used detach apparently removing them from the persistence context without ever making it to the database. --- jpa/pom.xml | 6 +----- .../SecureBusinessObjectRepository.java | 18 ++++++------------ .../jpa/security/SecurityIntegrationTests.java | 8 -------- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/jpa/pom.xml b/jpa/pom.xml index 28cbfdbc..bf7ef47b 100644 --- a/jpa/pom.xml +++ b/jpa/pom.xml @@ -23,16 +23,12 @@ java8 javaslang jpa21 - + security multiple-datasources eclipselink query-by-example - - 5.2.7.Final - - diff --git a/jpa/security/src/main/java/example/springdata/jpa/security/SecureBusinessObjectRepository.java b/jpa/security/src/main/java/example/springdata/jpa/security/SecureBusinessObjectRepository.java index 20102058..9b2dbb90 100644 --- a/jpa/security/src/main/java/example/springdata/jpa/security/SecureBusinessObjectRepository.java +++ b/jpa/security/src/main/java/example/springdata/jpa/security/SecureBusinessObjectRepository.java @@ -28,18 +28,12 @@ import org.springframework.data.repository.Repository; interface SecureBusinessObjectRepository extends Repository { /** - * Here we demonstrate the usage of SpEL expression within a custom query. - * With the {@link example.springdata.jpa.security.SecurityEvaluationContextExtension} in place - * we can safely access auth information provided by the Spring Security Context. - * - * The Spring Data Repository infrastructure will translate the given query string into the - * parameterized form: - * - * + * Here we demonstrate the usage of SpEL expression within a custom query. With the + * {@link example.springdata.jpa.security.SecurityEvaluationContextExtension} in place we can safely access auth + * information provided by the Spring Security Context. The Spring Data Repository infrastructure will translate the + * given query string into the parameterized form: * select o from BusinessObject o where o.owner.emailAddress like ? - * - * - * and set the the result SpEL expression evaluated at method invocation time as parameter value. + * and set the the result SpEL expression evaluated at method invocation time as parameter value. * * @return */ @@ -57,7 +51,7 @@ interface SecureBusinessObjectRepository extends Repository