diff --git a/src/main/java/org/springframework/data/mapping/PropertyPath.java b/src/main/java/org/springframework/data/mapping/PropertyPath.java index ca67478bf..ee99106b8 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 @@ import org.springframework.util.StringUtils; * @author Oliver Gierke * @author Christoph Strobl * @author Mark Paluch + * @author Mariusz Mączkowski */ @EqualsAndHashCode public class PropertyPath implements Streamable { @@ -401,7 +402,7 @@ public class PropertyPath implements Streamable { 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 a7dc52701..2905f2b46 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 @@ import org.springframework.data.repository.query.parser.PartTree.OrPart; * @author Christoph Strobl * @author Mark Paluch * @author Michael Cramer + * @author Mariusz Mączkowski */ public class PartTreeUnitTests { @@ -600,6 +601,16 @@ public class PartTreeUnitTests { 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 @@ public class PartTreeUnitTests { 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 {