Skip to content

Commit 6b3f35f

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

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.util.ArrayList;
2121
import java.util.Collection;
22+
import java.util.Collections;
2223
import java.util.Iterator;
2324
import java.util.List;
2425
import java.util.Optional;
@@ -412,7 +413,7 @@ public void shouldFindNodeEntititiesWithRelationshipEntityAndNestedProperty() {
412413
assertThat(users.contains(new User("Michal"))).isTrue();
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'}) ");
@@ -694,6 +695,19 @@ public void findByIdEqualsInDerivedQueryMethodShouldWork() {
694695
assertThat(users).hasSize(1);
695696
}
696697

698+
@Test // GH-1792
699+
public void findByIdInNestedPropertyTraversalShouldWork() {
700+
executeUpdate("CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500})"
701+
+ " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r) CREATE (m1:Movie {name:'Speed'})"
702+
+ " CREATE (g:Genre {name:'Thriller'}) CREATE (u)-[:INTERESTED]->(g)");
703+
704+
long genreId = session.queryForObject(Long.class, "MATCH (g:Genre {name:'Thriller'}) RETURN id(g)",
705+
Collections.emptyMap());
706+
707+
List<User> users = userRepository.findAllByInterestedId(genreId);
708+
assertThat(users).extracting(User::getName).containsExactly("Michal");
709+
}
710+
697711
@Test // DATAGRAPH-1093
698712
public void shouldFindNodeEntitiesByAttributeIgnoringCase() {
699713
executeUpdate("CREATE (:Director:Person {name:'Patty Jenkins'})\n" + //

0 commit comments

Comments
 (0)