From 5455b8c8dc21ab33463ccfb71494a4de878a5f6b Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Wed, 10 Feb 2016 18:19:32 +0100 Subject: [PATCH] DATAJPA-858 - Fixed collection contains handling for nested path traversals. Previously the first property was checked for being a collection to trigger collection contains handling. This is wrong for nested property traversals as they might end up in a String for which a like binding has to be applied then. We're now inspecting the leaf property for being a collection to trigger that special binding. --- .../data/jpa/repository/query/JpaQueryCreator.java | 2 +- .../data/jpa/repository/sample/UserRepository.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java b/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java index 33b744507..6768a644e 100644 --- a/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java +++ b/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java @@ -253,7 +253,7 @@ public class JpaQueryCreator extends AbstractQueryCreator> propertyExpression = traversePath(root, property); Expression parameterExpression = provider.next(part).getExpression(); diff --git a/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java b/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java index a3913dc01..0873375db 100644 --- a/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java +++ b/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java @@ -591,4 +591,9 @@ public interface UserRepository * DATAJPA-829 */ List findByRolesNotContaining(Role role); + + /** + * @see DATAJPA-858 + */ + List findByRolesNameContaining(String name); }