@@ -1288,6 +1288,33 @@ void shouldFindOneToOneWithWildcardReturn(@Autowired OneToOneRepository reposito
1288
1288
List <OneToOneSource > oneToOnes = repository .findAllWithCustomQueryReturnStar ();
1289
1289
assertOneToOneScenario (oneToOnes );
1290
1290
}
1291
+
1292
+ private void createOneToOneScenarioForNullValues () {
1293
+ doWithSession (session -> {
1294
+ try (Transaction tx = session .beginTransaction ()) {
1295
+ tx .run ("CREATE (s:OneToOneSource {name: 's1'}) -[:OWNS]->(t:OneToOneTarget {name: 't1'})" );
1296
+ tx .run ("CREATE (s:OneToOneSource {name: 's2'})" );
1297
+ tx .commit ();
1298
+ }
1299
+ return null ;
1300
+ }
1301
+ );
1302
+ }
1303
+
1304
+ private void assertOneToOneScenarioWithNulls (List <OneToOneSource > oneToOnes ) {
1305
+ assertThat (oneToOnes ).hasSize (2 );
1306
+ assertThat (oneToOnes ).extracting (OneToOneSource ::getName ).containsExactlyInAnyOrder ("s1" , "s2" );
1307
+ assertThat (oneToOnes ).filteredOn (s -> s .getTarget () != null )
1308
+ .extracting (s -> s .getTarget ().getName ()).containsExactly ("t1" );
1309
+ }
1310
+
1311
+ @ Test // GH-2305
1312
+ void shouldFindOneToOneWithNullValues (@ Autowired OneToOneRepository repository ) {
1313
+ createOneToOneScenarioForNullValues ();
1314
+
1315
+ List <OneToOneSource > oneToOnes = repository .findAllWithNullValues ();
1316
+ assertOneToOneScenarioWithNulls (oneToOnes );
1317
+ }
1291
1318
}
1292
1319
1293
1320
@ Nested
@@ -4118,6 +4145,9 @@ interface OneToOneRepository extends Neo4jRepository<OneToOneSource, String> {
4118
4145
4119
4146
@ Query ("MATCH (p1:#{#staticLabels})-[r:OWNS]-(p2) return *" )
4120
4147
List <OneToOneSource > findAllWithCustomQueryReturnStar ();
4148
+
4149
+ @ Query ("MATCH (p1:#{#staticLabels}) OPTIONAL MATCH (p1)-[r:OWNS]->(p2) return p1, r, p2" )
4150
+ List <OneToOneSource > findAllWithNullValues ();
4121
4151
}
4122
4152
4123
4153
interface RelationshipRepository extends Neo4jRepository <PersonWithRelationship , Long > {
0 commit comments