GH-1792 - Ensure that internal database ids are accessed via id(n) in nested, derived query methods.
This closes #1792.
This commit is contained in:
@@ -151,6 +151,8 @@ public interface UserRepository extends PersonRepository<User, Long> {
|
||||
|
||||
List<User> findAllByIdAndName(Long id, String name);
|
||||
|
||||
List<User> findAllByInterestedId(Long id);
|
||||
|
||||
@Query("invalid")
|
||||
void invalidQuery();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -412,7 +413,7 @@ public class DerivedQueryTests {
|
||||
assertTrue(users.contains(new User("Michal")));
|
||||
}
|
||||
|
||||
@Test // Relates to DATAGRAPH-601 and, to an extent, DATAGRAPH-761
|
||||
@Test // DATAGRAPH-601, DATAGRAPH-761
|
||||
public void shouldFindNodeEntitiesByRegularExpressionMatchingOnPropertiesInDerivedFinderMethods() {
|
||||
executeUpdate("CREATE (:Theatre {name:'Odeon', city:'Preston'}), " + "(:Theatre {name:'Vue', city:'Dumfries'}), "
|
||||
+ "(:Theatre {name:'PVR', city:'Mumbai'}) ");
|
||||
@@ -683,6 +684,20 @@ public class DerivedQueryTests {
|
||||
assertThat(users).hasSize(1);
|
||||
}
|
||||
|
||||
@Test // GH-1792
|
||||
public void findByIdInNestedPropertyTraversalShouldWork() {
|
||||
executeUpdate("CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500})"
|
||||
+ " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r) CREATE (m1:Movie {name:'Speed'})"
|
||||
+ " CREATE (g:Genre {name:'Thriller'}) CREATE (u)-[:INTERESTED]->(g)");
|
||||
|
||||
long genreId = session.queryForObject(Long.class, "MATCH (g:Genre {name:'Thriller'}) RETURN id(g)",
|
||||
Collections.emptyMap());
|
||||
|
||||
List<User> users = userRepository.findAllByInterestedId(genreId);
|
||||
assertEquals(1, users.size());
|
||||
assertEquals("Michal", users.get(0).getName());
|
||||
}
|
||||
|
||||
@Test // DATAGRAPH-1093
|
||||
public void shouldFindNodeEntitiesByAttributeIgnoringCase() {
|
||||
executeUpdate("CREATE (:Director:Person {name:'Patty Jenkins'})\n" + //
|
||||
|
||||
Reference in New Issue
Block a user