Skip to content

Commit 0065963

Browse files
fix: Assume Values.NULL in all cases where id values are literal null.
Closes #2710
1 parent 41adae2 commit 0065963

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

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

Lines changed: 11 additions & 3 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;
@@ -308,16 +309,23 @@ entityMetaData, convertIdValues(entityMetaData.getRequiredIdProperty(), ids)))
308309
.getResults();
309310
}
310311

311-
private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, Object idValues) {
312+
private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, @Nullable Object idValues) {
312313

313314
if (idProperty != null && ((Neo4jPersistentEntity<?>) idProperty.getOwner()).isUsingInternalIds()) {
314315
return idValues;
315316
}
316317

317-
return neo4jMappingContext.getConversionService().writeValue(idValues, TypeInformation.of(idValues.getClass()),
318-
idProperty == null ? null : idProperty.getOptionalConverter());
318+
if (idValues != null) {
319+
return neo4jMappingContext.getConversionService().writeValue(idValues, TypeInformation.of(idValues.getClass()), idProperty == null ? null : idProperty.getOptionalConverter());
320+
} else if (idProperty != null) {
321+
return neo4jMappingContext.getConversionService().writeValue(idValues, idProperty.getTypeInformation(), idProperty.getOptionalConverter());
322+
} else {
323+
// Not much we can convert here
324+
return Values.NULL;
325+
}
319326
}
320327

328+
321329
@Override
322330
public <T> T save(T instance) {
323331

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;
@@ -307,15 +308,20 @@ public <T> Mono<ExecutableQuery<T>> toExecutableQuery(Class<T> domainType,
307308
return createExecutableQuery(domainType, null, queryFragmentsAndParameters);
308309
}
309310

311+
private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, @Nullable Object idValues) {
310312

311-
private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, Object idValues) {
312-
313-
if (((Neo4jPersistentEntity<?>) idProperty.getOwner()).isUsingInternalIds()) {
313+
if (idProperty != null && ((Neo4jPersistentEntity<?>) idProperty.getOwner()).isUsingInternalIds()) {
314314
return idValues;
315315
}
316316

317-
return neo4jMappingContext.getConversionService().writeValue(idValues,
318-
TypeInformation.of(idValues.getClass()), idProperty == null ? null : idProperty.getOptionalConverter());
317+
if (idValues != null) {
318+
return neo4jMappingContext.getConversionService().writeValue(idValues, TypeInformation.of(idValues.getClass()), idProperty == null ? null : idProperty.getOptionalConverter());
319+
} else if (idProperty != null) {
320+
return neo4jMappingContext.getConversionService().writeValue(idValues, idProperty.getTypeInformation(), idProperty.getOptionalConverter());
321+
} else {
322+
// Not much we can convert here
323+
return Values.NULL;
324+
}
319325
}
320326

321327
@Override

0 commit comments

Comments
 (0)