Skip to content

Commit cc75e02

Browse files
GH-1792 - Ensure that internal database ids are accessed via id(n) in nested, derived query methods.
This closes #1792.
1 parent 2d4fac8 commit cc75e02

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/UserRepository.java

+2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ public interface UserRepository extends PersonRepository<User, Long> {
151151

152152
List<User> findAllByIdAndName(Long id, String name);
153153

154+
List<User> findAllByInterestedId(Long id);
155+
154156
@Query("invalid")
155157
void invalidQuery();
156158

spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/DerivedQueryTests.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.util.ArrayList;
2323
import java.util.Collection;
24+
import java.util.Collections;
2425
import java.util.Iterator;
2526
import java.util.List;
2627
import java.util.Optional;
@@ -412,7 +413,7 @@ public void shouldFindNodeEntititiesWithRelationshipEntityAndNestedProperty() {
412413
assertTrue(users.contains(new User("Michal")));
413414
}
414415

415-
@Test // Relates to DATAGRAPH-601 and, to an extent, DATAGRAPH-761
416+
@Test // DATAGRAPH-601, DATAGRAPH-761
416417
public void shouldFindNodeEntitiesByRegularExpressionMatchingOnPropertiesInDerivedFinderMethods() {
417418
executeUpdate("CREATE (:Theatre {name:'Odeon', city:'Preston'}), " + "(:Theatre {name:'Vue', city:'Dumfries'}), "
418419
+ "(:Theatre {name:'PVR', city:'Mumbai'}) ");
@@ -683,6 +684,20 @@ public void findByIdEqualsInDerivedQueryMethodShouldWork() {
683684
assertThat(users).hasSize(1);
684685
}
685686

687+
@Test // GH-1792
688+
public void findByIdInNestedPropertyTraversalShouldWork() {
689+
executeUpdate("CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500})"
690+
+ " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r) CREATE (m1:Movie {name:'Speed'})"
691+
+ " CREATE (g:Genre {name:'Thriller'}) CREATE (u)-[:INTERESTED]->(g)");
692+
693+
long genreId = session.queryForObject(Long.class, "MATCH (g:Genre {name:'Thriller'}) RETURN id(g)",
694+
Collections.emptyMap());
695+
696+
List<User> users = userRepository.findAllByInterestedId(genreId);
697+
assertEquals(1, users.size());
698+
assertEquals("Michal", users.get(0).getName());
699+
}
700+
686701
@Test // DATAGRAPH-1093
687702
public void shouldFindNodeEntitiesByAttributeIgnoringCase() {
688703
executeUpdate("CREATE (:Director:Person {name:'Patty Jenkins'})\n" + //

0 commit comments

Comments
 (0)