diff --git a/pom.xml b/pom.xml
index 37b3d78c8c..0b4cb6273d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-jdbc
- 1.0.0.BUILD-SNAPSHOT
+ 1.0.0.DATAJDBC-142-SNAPSHOT
Spring Data JDBC
Spring Data module for JDBC repositories.
diff --git a/src/main/java/org/springframework/data/jdbc/mapping/model/JdbcMappingContext.java b/src/main/java/org/springframework/data/jdbc/mapping/model/JdbcMappingContext.java
index 570d4a8f92..d718d7dab0 100644
--- a/src/main/java/org/springframework/data/jdbc/mapping/model/JdbcMappingContext.java
+++ b/src/main/java/org/springframework/data/jdbc/mapping/model/JdbcMappingContext.java
@@ -83,7 +83,7 @@ public List referencedEntities(Class> rootType, PropertyPath pat
if (property.isEntity()) {
PropertyPath nextPath = path == null ? PropertyPath.from(property.getName(), rootType)
- : path.nested(property.getColumnName());
+ : path.nested(property.getName());
paths.add(nextPath);
paths.addAll(referencedEntities(rootType, nextPath));
}
diff --git a/src/test/java/org/springframework/data/jdbc/mapping/model/JdbcMappingContextUnitTests.java b/src/test/java/org/springframework/data/jdbc/mapping/model/JdbcMappingContextUnitTests.java
new file mode 100644
index 0000000000..0bdcd9fd75
--- /dev/null
+++ b/src/test/java/org/springframework/data/jdbc/mapping/model/JdbcMappingContextUnitTests.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.jdbc.mapping.model;
+
+import org.junit.Test;
+import org.springframework.data.mapping.PropertyPath;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+/**
+ * Unit tests for {@link JdbcMappingContext}.
+ *
+ * @author Jens Schauder
+ */
+public class JdbcMappingContextUnitTests {
+
+ NamingStrategy namingStrategy = new DefaultNamingStrategy();
+ NamedParameterJdbcOperations jdbcTemplate = mock(NamedParameterJdbcOperations.class);
+ ConversionCustomizer customizer = mock(ConversionCustomizer.class);
+
+ @Test // DATAJDBC-142
+ public void referencedEntitiesGetFound() {
+
+ JdbcMappingContext mappingContext = new JdbcMappingContext(namingStrategy, jdbcTemplate, customizer);
+
+ List propertyPaths = mappingContext.referencedEntities(DummyEntity.class, null);
+
+ assertThat(propertyPaths) //
+ .extracting(PropertyPath::toDotPath) //
+ .containsExactly( //
+ "one.two", //
+ "one" //
+ );
+ }
+
+ @Test // DATAJDBC-142
+ public void propertyPathDoesNotDependOnNamingStrategy() {
+
+ namingStrategy = mock(NamingStrategy.class);
+
+ JdbcMappingContext mappingContext = new JdbcMappingContext(namingStrategy, jdbcTemplate, customizer);
+
+ List propertyPaths = mappingContext.referencedEntities(DummyEntity.class, null);
+
+ assertThat(propertyPaths) //
+ .extracting(PropertyPath::toDotPath) //
+ .containsExactly( //
+ "one.two", //
+ "one" //
+ );
+ }
+
+ private static class DummyEntity {
+
+ String simpleProperty;
+
+ LevelOne one;
+ }
+
+ private static class LevelOne {
+ LevelTwo two;
+ }
+
+ private static class LevelTwo {
+ String someValue;
+ }
+}
\ No newline at end of file