diff --git a/src/main/java/org/springframework/data/mapping/PropertyPath.java b/src/main/java/org/springframework/data/mapping/PropertyPath.java index ca67478bf1..ee99106b82 100644 --- a/src/main/java/org/springframework/data/mapping/PropertyPath.java +++ b/src/main/java/org/springframework/data/mapping/PropertyPath.java @@ -42,6 +42,7 @@ * @author Oliver Gierke * @author Christoph Strobl * @author Mark Paluch + * @author Mariusz Mączkowski */ @EqualsAndHashCode public class PropertyPath implements Streamable { @@ -401,7 +402,7 @@ private static PropertyPath create(String source, TypeInformation type, Strin exception = e; } - Pattern pattern = Pattern.compile("\\p{Lu}+\\p{Ll}*$"); + Pattern pattern = Pattern.compile("\\p{Lu}\\p{Ll}*$"); Matcher matcher = pattern.matcher(source); if (matcher.find() && matcher.start() != 0) { diff --git a/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java b/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java index a7dc527016..2905f2b46d 100755 --- a/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java +++ b/src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java @@ -44,6 +44,7 @@ * @author Christoph Strobl * @author Mark Paluch * @author Michael Cramer + * @author Mariusz Mączkowski */ public class PartTreeUnitTests { @@ -600,6 +601,16 @@ public void emptyTreeDoesNotContainParts() { assertThat(tree.hasPredicate()).isFalse(); } + @Test // DATACMNS-1304 + public void resolvesPropertyPathWithSingleUppercaseLetterPropertyEnding() { + assertThat(new PartTree("findByCategoryBId", Product.class)).isNotNull(); + } + + @Test // DATACMNS-1304 + public void resolvesPropertyPathWithUppercaseLettersPropertyEnding() { + assertThat(new PartTree("findByCategoryABId", Product.class)).isNotNull(); + } + private static void assertLimiting(String methodName, Class entityType, boolean limiting, Integer maxResults) { assertLimiting(methodName, entityType, limiting, maxResults, false); } @@ -723,6 +734,10 @@ interface Product { Anders getAnders(); // constains And keyword Category getCategory(); + + Category getCategoryB(); // contains single uppercase letter at the end + + Category getCategoryAB(); // contains uppercase letters at the end } interface Category {