Skip to content

Commit 30c905a

Browse files
fix: Assume Values.NULL in all cases where id values are literal null.
Closes #2710 # Conflicts: # src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java # src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java
1 parent 33e9f33 commit 30c905a

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.neo4j.cypherdsl.core.renderer.Configuration;
4949
import org.neo4j.cypherdsl.core.renderer.Renderer;
5050
import org.neo4j.driver.Value;
51+
import org.neo4j.driver.Values;
5152
import org.neo4j.driver.exceptions.NoSuchRecordException;
5253
import org.neo4j.driver.summary.ResultSummary;
5354
import org.neo4j.driver.types.Entity;
@@ -335,15 +336,20 @@ entityMetaData, convertIdValues(entityMetaData.getRequiredIdProperty(), ids)))
335336
.getResults();
336337
}
337338

338-
private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, Object idValues) {
339+
private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, @Nullable Object idValues) {
339340

340341
if (idProperty != null && ((Neo4jPersistentEntity<?>) idProperty.getOwner()).isUsingInternalIds()) {
341342
return idValues;
342343
}
343344

344-
return neo4jMappingContext.getConversionService().writeValue(idValues,
345-
ClassTypeInformation.from(idValues.getClass()),
346-
idProperty == null ? null : idProperty.getOptionalConverter());
345+
if (idValues != null) {
346+
return neo4jMappingContext.getConversionService().writeValue(idValues, ClassTypeInformation.from(idValues.getClass()), idProperty == null ? null : idProperty.getOptionalConverter());
347+
} else if (idProperty != null) {
348+
return neo4jMappingContext.getConversionService().writeValue(idValues, idProperty.getTypeInformation(), idProperty.getOptionalConverter());
349+
} else {
350+
// Not much we can convert here
351+
return Values.NULL;
352+
}
347353
}
348354

349355
@Override

src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.neo4j.cypherdsl.core.Cypher.asterisk;
2020
import static org.neo4j.cypherdsl.core.Cypher.parameter;
2121

22+
import org.neo4j.driver.Values;
2223
import org.springframework.data.neo4j.core.mapping.IdDescription;
2324
import reactor.core.publisher.Flux;
2425
import reactor.core.publisher.Mono;
@@ -320,15 +321,20 @@ public <T> Mono<ExecutableQuery<T>> toExecutableQuery(Class<T> domainType,
320321
return createExecutableQuery(domainType, null, queryFragmentsAndParameters);
321322
}
322323

324+
private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, @Nullable Object idValues) {
323325

324-
private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, Object idValues) {
325-
326-
if (((Neo4jPersistentEntity<?>) idProperty.getOwner()).isUsingInternalIds()) {
326+
if (idProperty != null && ((Neo4jPersistentEntity<?>) idProperty.getOwner()).isUsingInternalIds()) {
327327
return idValues;
328328
}
329329

330-
return neo4jMappingContext.getConversionService().writeValue(idValues,
331-
ClassTypeInformation.from(idValues.getClass()), idProperty == null ? null : idProperty.getOptionalConverter());
330+
if (idValues != null) {
331+
return neo4jMappingContext.getConversionService().writeValue(idValues, ClassTypeInformation.from(idValues.getClass()), idProperty == null ? null : idProperty.getOptionalConverter());
332+
} else if (idProperty != null) {
333+
return neo4jMappingContext.getConversionService().writeValue(idValues, idProperty.getTypeInformation(), idProperty.getOptionalConverter());
334+
} else {
335+
// Not much we can convert here
336+
return Values.NULL;
337+
}
332338
}
333339

334340
@Override

0 commit comments

Comments
 (0)