From f9d326e32d2f80602b22c996d64749b1165752f7 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Mon, 19 May 2014 08:58:33 +0200 Subject: [PATCH] DATACMNS-506 - Added section on escaping underscores in query method names. We now explicitly discuss the case of referring to properties with underscores (e.g. first_name) in repository query methods. Added missing language declaration for a code block. --- src/docbkx/repositories.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/docbkx/repositories.xml b/src/docbkx/repositories.xml index 2048e3c99..7253b4152 100644 --- a/src/docbkx/repositories.xml +++ b/src/docbkx/repositories.xml @@ -456,6 +456,12 @@ OG Does that make sense with my comment above?-->To resolve this ambiguity you List<Person> findByAddress_ZipCode(ZipCode zipCode); + + If your property names contain underscores (e.g. + first_name) you can escape the underscore in the method + name with a second underscore. For a first_name property + the query method would have to be named + findByFirst__name(…).
@@ -471,7 +477,7 @@ OG Does that make sense with my comment above?-->To resolve this ambiguity you Using Pageable and Sort in query methods - Page<User> findByLastname(String lastname, Pageable pageable); + Page<User> findByLastname(String lastname, Pageable pageable); List<User> findByLastname(String lastname, Sort sort);