@@ -777,6 +777,30 @@ void findDeepSameLabelsAndTypeRelationships(@Autowired PetRepository repository)
777
777
778
778
}
779
779
780
+ @ Test
781
+ void findBySameLabelRelationshipProperty (@ Autowired PetRepository repository ) {
782
+ try (Session session = createSession ()) {
783
+ session .run ("CREATE (p1:Pet{name: 'Pet1'})-[:Has]->(p2:Pet{name: 'Pet2'})" );
784
+ }
785
+
786
+ Pet pet = repository .findByFriendsName ("Pet2" );
787
+ assertThat (pet ).isNotNull ();
788
+ assertThat (pet .getFriends ()).isNotEmpty ();
789
+ }
790
+
791
+ @ Test
792
+ void findBySameLabelRelationshipPropertyMultipleLevels (@ Autowired PetRepository repository ) {
793
+ try (Session session = createSession ()) {
794
+ session .run (
795
+ "CREATE (p1:Pet{name: 'Pet1'})-[:Has]->(p2:Pet{name: 'Pet2'})-[:Has]->(p3:Pet{name: 'Pet3'})" );
796
+ }
797
+
798
+ Pet pet = repository .findByFriendsFriendsName ("Pet3" );
799
+ assertThat (pet ).isNotNull ();
800
+ assertThat (pet .getFriends ()).isNotEmpty ();
801
+ assertThat (pet .getFriends ().get (0 ).getFriends ()).isNotEmpty ();
802
+ }
803
+
780
804
@ Test
781
805
void findLoopingDeepRelationships (@ Autowired LoopingRelationshipRepository loopingRelationshipRepository ) {
782
806
@@ -3361,6 +3385,10 @@ interface PetRepository extends Neo4jRepository<Pet, Long> {
3361
3385
countQuery = "MATCH (p:Pet) return count(p)" )
3362
3386
Page <Pet > pagedPetsWithParameter (@ Param ("petName" ) String petName , Pageable pageable );
3363
3387
3388
+ Pet findByFriendsName (String friendName );
3389
+
3390
+ Pet findByFriendsFriendsName (String friendName );
3391
+
3364
3392
}
3365
3393
3366
3394
interface RelationshipRepository extends Neo4jRepository <PersonWithRelationship , Long > {
0 commit comments