diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/mapping/PropertyPath.java b/spring-data-commons-core/src/main/java/org/springframework/data/mapping/PropertyPath.java index b77232e47..a05a8667e 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/mapping/PropertyPath.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/mapping/PropertyPath.java @@ -35,6 +35,7 @@ import org.springframework.util.StringUtils; public class PropertyPath implements Iterable { private static final String DELIMITERS = "_\\."; + private static final String ALL_UPPERCASE = "[A-Z0-9._$]+"; private static final Pattern SPLITTER = Pattern.compile("(?:[%s]?([%s]*?[^%s]+))".replaceAll("%s", DELIMITERS)); private final TypeInformation owningType; @@ -67,7 +68,7 @@ public class PropertyPath implements Iterable { Assert.hasText(name); Assert.notNull(owningType); - String propertyName = StringUtils.uncapitalize(name); + String propertyName = name.matches(ALL_UPPERCASE) ? name : StringUtils.uncapitalize(name); TypeInformation type = owningType.getProperty(propertyName); if (type == null) { diff --git a/spring-data-commons-core/src/test/java/org/springframework/data/mapping/PropertyPathUnitTests.java b/spring-data-commons-core/src/test/java/org/springframework/data/mapping/PropertyPathUnitTests.java index 1c8c60443..26dff01ef 100644 --- a/spring-data-commons-core/src/test/java/org/springframework/data/mapping/PropertyPathUnitTests.java +++ b/spring-data-commons-core/src/test/java/org/springframework/data/mapping/PropertyPathUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 the original author or authors. + * Copyright 2011-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -281,10 +281,37 @@ public class PropertyPathUnitTests { assertThat(left.hashCode(), is(not(shortPath.hashCode()))); } + /** + * @see DATACMNS-257 + */ + @Test + public void findsAllUppercaseProperty() { + + PropertyPath path = PropertyPath.from("UUID", Foo.class); + + assertThat(path, is(notNullValue())); + assertThat(path.getSegment(), is("UUID")); + } + + /** + * @see DATACMNS-257 + */ + @Test + public void findsNestedAllUppercaseProperty() { + + PropertyPath path = PropertyPath.from("_fooUUID", Sample2.class); + + assertThat(path, is(notNullValue())); + assertThat(path.getSegment(), is("_foo")); + assertThat(path.hasNext(), is(true)); + assertThat(path.next().getSegment(), is("UUID")); + } + private class Foo { String userName; String _email; + String UUID; } private class Bar {