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;
|
||||
@@ -123,10 +124,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertFalse(iterator.hasNext());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-628
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-628
|
||||
public void shouldFindNodeEntitiesWithLabels() {
|
||||
executeUpdate(
|
||||
"CREATE (u:User {name:'Michal'}) CREATE (p:Theatre {name:'Picturehouse', city:'London'}) CREATE (r:Theatre {name:'Ritzy', city:'London'}) CREATE (u)-[:VISITED]->(p)");
|
||||
@@ -170,10 +168,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldFindNodeEntitiesMultipleAndedProperties() {
|
||||
executeUpdate(
|
||||
"CREATE (p:Theatre {name:'Picturehouse', city:'London'}) CREATE (r:Theatre {name:'Ritzy', city:'London'})"
|
||||
@@ -184,10 +179,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertEquals("Michal", theatres.get(0).getVisited().iterator().next().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldFindNodeEntititiesMultipleOredProperties() {
|
||||
executeUpdate(
|
||||
"CREATE (p:Theatre {name:'Picturehouse', city:'London'}) CREATE (r:Theatre {name:'Ritzy', city:'London'})"
|
||||
@@ -197,10 +189,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertEquals(2, theatres.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldReturnNoResultsCorrectly() {
|
||||
executeUpdate(
|
||||
"CREATE (p:Theatre {name:'Picturehouse', city:'London'}) CREATE (r:Theatre {name:'Ritzy', city:'London'})"
|
||||
@@ -210,10 +199,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertEquals(0, theatres.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldFindNodeEntititiesWithComparisonOperators() {
|
||||
executeUpdate(
|
||||
"CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500})"
|
||||
@@ -243,10 +229,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldFindNodeEntititiesWithMultipleComparisonOperatorsAnded() {
|
||||
executeUpdate(
|
||||
"CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) CREATE (m:Theatre {name:'Regal', city:'Bombay', capacity: 4500})"
|
||||
@@ -267,10 +250,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldFindNodeEntititiesWithMultipleComparisonOperatorsOred() {
|
||||
executeUpdate(
|
||||
"CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) CREATE (m:Theatre {name:'Regal', city:'Bombay', capacity: 9000})"
|
||||
@@ -291,10 +271,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldFindNodeEntititiesWithNestedProperty() {
|
||||
executeUpdate(
|
||||
"CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500})"
|
||||
@@ -305,10 +282,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertTrue(theatres.contains(new Cinema("Ritzy")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-???
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-???
|
||||
public void shouldFindNodeEntititiesWithDeepNestedProperty() {
|
||||
executeUpdate("CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500})"
|
||||
+ " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r) CREATE (m1:Movie {name:'Speed'})"
|
||||
@@ -319,10 +293,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertTrue(theatres.contains(new Cinema("Ritzy")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldFindNodeEntititiesWithBaseAndNestedProperty() {
|
||||
executeUpdate(
|
||||
"CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) CREATE (m:Theatre {name:'Regal', city:'Bombay', capacity: 5000})"
|
||||
@@ -333,10 +304,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertTrue(theatres.contains(new Cinema("Ritzy")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-662 //TODO FIXME
|
||||
*/
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test(expected = UnsupportedOperationException.class) // DATAGRAPH-662
|
||||
public void shouldFindNodeEntititiesWithBaseOrNestedProperty() {
|
||||
executeUpdate(
|
||||
"CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) CREATE (m:Theatre {name:'The Old Vic', city:'London', capacity: 5000})"
|
||||
@@ -349,10 +317,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertTrue(theatres.contains(new Cinema("The Old Vic")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-632
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-632
|
||||
public void shouldFindNodeEntitiesWithNestedRelationshipEntityProperty() {
|
||||
executeUpdate(
|
||||
"CREATE (m1:Movie {title:'Speed'}) CREATE (m2:Movie {title:'The Matrix'}) CREATE (m:Movie {title:'Chocolat'})"
|
||||
@@ -365,11 +330,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertTrue(users.contains(new User("Vince")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
* @see DATAGRAPH-705
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629 DATAGRAPH-705
|
||||
public void shouldFindNodeEntititiesWithTwoNestedPropertiesAndedAcrossDifferentRelatedNodeEntities() {
|
||||
executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) "
|
||||
+ " CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " + " CREATE (u:User {name:'Michal'}) "
|
||||
@@ -390,11 +351,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-662
|
||||
*/
|
||||
// FIXME: OR is not supported for nested properties on an entity
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Test(expected = UnsupportedOperationException.class) // DATAGRAPH-662
|
||||
public void shouldFindNodeEntititiesWithTwoNestedPropertiesOred() {
|
||||
executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) "
|
||||
+ " CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " + " CREATE (u:User {name:'Michal'}) "
|
||||
@@ -416,10 +373,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldFindNodeEntititiesWithMultipleNestedPropertiesAnded() {
|
||||
executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) "
|
||||
+ " CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) "
|
||||
@@ -439,10 +393,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-629
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-629
|
||||
public void shouldFindNodeEntititiesWithRelationshipEntityAndNestedProperty() {
|
||||
executeUpdate(
|
||||
"CREATE (m1:Movie {title:'Speed'}) CREATE (m2:Movie {title:'The Matrix'}) CREATE (m:Movie {title:'Chocolat'})"
|
||||
@@ -454,10 +405,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertTrue(users.contains(new User("Michal")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Relates to DATAGRAPH-601 and, to an extent, DATAGRAPH-761
|
||||
*/
|
||||
@Test
|
||||
@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'}) ");
|
||||
@@ -468,10 +416,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertEquals("An unexpected cinema was retrieved", "Dumfries", cinemas.get(0).getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* DATAGRAPH-761
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-761
|
||||
public void shouldMatchNodeEntitiesUsingCaseInsensitiveLikeWithWildcards() {
|
||||
executeUpdate("CREATE (:Theatre {name:'IMAX', city:'Chesterfield'}), "
|
||||
+ "(:Theatre {name:'Odeon', city:'Manchester'}), " + "(:Theatre {name:'IMAX', city:'Edinburgh'}) ");
|
||||
@@ -480,10 +425,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertEquals("The wrong number of cinemas was returned", 2, cinemas.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* DATAGRAPH-761
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-761
|
||||
public void shouldMatchNodeEntitiesUsingLikeWithWildcardsAndSpecialCharacters() {
|
||||
executeUpdate("CREATE (:Theatre {name:'IMAX', city:'Kolkata (Calcutta)'}), "
|
||||
+ "(:Theatre {name:'PVR', city:'Bengaluru (Bangalore)'}), "
|
||||
@@ -493,10 +435,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertEquals("The wrong number of cinemas was returned", 2, indianCinemas.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* DATAGRAPH-761
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-761
|
||||
public void shouldMatchNodeEntitiesUsingNotLikeWithAsteriskWildcards() {
|
||||
executeUpdate("CREATE (:User {name:'Jeff'}), " + "(:User {name:'Jeremy'}), " + "(:User {name:'Alan'})");
|
||||
|
||||
@@ -505,10 +444,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertEquals("The wrong user was returned", "Alan", nonMatchingUsers.get(0).getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-787
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-787
|
||||
public void shouldFindDirectorsByName() {
|
||||
executeUpdate(
|
||||
"CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'}) CREATE (d:Director {name:'Vince'})");
|
||||
@@ -530,10 +466,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-744
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-744
|
||||
public void shouldFindUserWithCustomDepth() {
|
||||
executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) "
|
||||
+ " CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " + " CREATE (u:User {name:'Michal'}) "
|
||||
@@ -567,10 +500,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-744
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-744
|
||||
public void shouldFindUsersByNameWithStaticDepth() {
|
||||
executeUpdate(
|
||||
"CREATE (m:User {name:'Michal', surname:'Bachman'})<-[:FRIEND_OF]-(a:User {name:'Adam', surname:'George'})");
|
||||
@@ -582,10 +512,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertEquals(0, user.getFriends().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-864
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-864
|
||||
public void shouldSupportLiteralMapsInQueryResults() {
|
||||
executeUpdate(
|
||||
"CREATE (m1:Movie {title:'Speed'}) CREATE (m2:Movie {title:'The Matrix'}) CREATE (m:Movie {title:'Chocolat'})"
|
||||
@@ -605,11 +532,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InterruptedException
|
||||
* @see DATAGRAPH-876
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-876
|
||||
public void shouldAllowMultiThreadedDerivedFinderExecution() throws InterruptedException {
|
||||
int numThreads = 3;
|
||||
executeUpdate(
|
||||
@@ -630,10 +553,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-680
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-680
|
||||
@Transactional
|
||||
public void shouldPageDerivedFinderQueries() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
@@ -675,10 +595,7 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
assertFalse(page.hasNext());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAGRAPH-680
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAGRAPH-680
|
||||
@Transactional
|
||||
public void shouldSliceDerivedFinderQueries() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
@@ -759,6 +676,20 @@ public class DerivedQueryTests extends MultiDriverTestClass {
|
||||
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 {name:'Patty Jenkins'})\n" + //
|
||||
|
||||
Reference in New Issue
Block a user