diff --git a/pom.xml b/pom.xml index 02d367247..e26bbc9db 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ ${skipTests} 8.40 4.8.149 - 2023.2.0 + 2023.9.5 spring-data-neo4j SDNEO4J 1.2.5 @@ -118,6 +118,13 @@ + + org.neo4j + neo4j-cypher-dsl-bom + ${cypher-dsl.version} + pom + import + com.google.code.findbugs jsr305 @@ -187,22 +194,6 @@ neo4j ${neo4j.version} - - org.neo4j - neo4j-cypher-dsl - ${cypher-dsl.version} - - - annotations - org.jetbrains - - - - - org.neo4j - neo4j-cypher-dsl-schema-name-support - ${cypher-dsl.version} - org.neo4j.driver neo4j-java-driver diff --git a/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java b/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java index 55dd9603e..0caea2c1d 100644 --- a/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java +++ b/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java @@ -43,7 +43,6 @@ import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Condition; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.FunctionInvocation; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Named; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.Statement; @@ -190,7 +189,7 @@ public final class Neo4jTemplate implements public long count(Class domainType) { Neo4jPersistentEntity entityMetaData = neo4jMappingContext.getRequiredPersistentEntity(domainType); - Statement statement = cypherGenerator.prepareMatchOf(entityMetaData).returning(Functions.count(asterisk())) + Statement statement = cypherGenerator.prepareMatchOf(entityMetaData).returning(Cypher.count(asterisk())) .build(); return count(statement); diff --git a/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java b/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java index 50b2ffdac..813cf61d3 100644 --- a/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java +++ b/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java @@ -20,7 +20,6 @@ import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Condition; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.FunctionInvocation; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Named; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.Statement; @@ -179,7 +178,7 @@ public final class ReactiveNeo4jTemplate implements public Mono count(Class domainType) { Neo4jPersistentEntity entityMetaData = neo4jMappingContext.getRequiredPersistentEntity(domainType); - Statement statement = cypherGenerator.prepareMatchOf(entityMetaData).returning(Functions.count(asterisk())).build(); + Statement statement = cypherGenerator.prepareMatchOf(entityMetaData).returning(Cypher.count(asterisk())).build(); return count(statement); } diff --git a/src/main/java/org/springframework/data/neo4j/core/TemplateSupport.java b/src/main/java/org/springframework/data/neo4j/core/TemplateSupport.java index 95113e4bc..7eab09d26 100644 --- a/src/main/java/org/springframework/data/neo4j/core/TemplateSupport.java +++ b/src/main/java/org/springframework/data/neo4j/core/TemplateSupport.java @@ -36,7 +36,6 @@ import java.util.stream.StreamSupport; import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.FunctionInvocation; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Named; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.Relationship; @@ -187,7 +186,7 @@ public final class TemplateSupport { private final static String RELATED_NODE_IDS = "relatedNodeIds"; final static NodesAndRelationshipsByIdStatementProvider EMPTY = - new NodesAndRelationshipsByIdStatementProvider(Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), new QueryFragments(), SpringDataCypherDsl.elementIdOrIdFunction.apply(Dialect.DEFAULT)); + new NodesAndRelationshipsByIdStatementProvider(Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), new QueryFragments(), SpringDataCypherDsl.elementIdOrIdFunction.apply(Dialect.NEO4J_4)); private final Map> parameters = new HashMap<>(3); private final QueryFragments queryFragments; @@ -223,16 +222,16 @@ public final class TemplateSupport { Relationship relationships = Cypher.anyNode().relationshipBetween(Cypher.anyNode()).named(RELATIONSHIP_IDS); return Cypher.match(rootNodes) .where(elementIdFunction.apply(rootNodes).in(Cypher.parameter(ROOT_NODE_IDS))) - .with(Functions.collect(rootNodes).as(Constants.NAME_OF_ROOT_NODE)) + .with(Cypher.collect(rootNodes).as(Constants.NAME_OF_ROOT_NODE)) .optionalMatch(relationships) .where(elementIdFunction.apply(relationships).in(Cypher.parameter(RELATIONSHIP_IDS))) - .with(Constants.NAME_OF_ROOT_NODE, Functions.collectDistinct(relationships).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS)) + .with(Constants.NAME_OF_ROOT_NODE, Cypher.collectDistinct(relationships).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS)) .optionalMatch(relatedNodes) .where(elementIdFunction.apply(relatedNodes).in(Cypher.parameter(RELATED_NODE_IDS))) .with( Constants.NAME_OF_ROOT_NODE, Cypher.name(Constants.NAME_OF_SYNTHESIZED_RELATIONS).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS), - Functions.collectDistinct(relatedNodes).as(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES) + Cypher.collectDistinct(relatedNodes).as(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES) ) .unwind(Constants.NAME_OF_ROOT_NODE).as(ROOT_NODE_IDS) .with( @@ -431,7 +430,7 @@ public final class TemplateSupport { } static boolean rendererRendersElementId(Renderer renderer) { - return renderer.render(Cypher.returning(Functions.elementId(Cypher.anyNode("n"))).build()) + return renderer.render(Cypher.returning(Cypher.elementId(Cypher.anyNode("n"))).build()) .equals("RETURN elementId(n)"); } diff --git a/src/main/java/org/springframework/data/neo4j/core/mapping/CypherGenerator.java b/src/main/java/org/springframework/data/neo4j/core/mapping/CypherGenerator.java index 81c0f98c5..0c0b2c7c7 100644 --- a/src/main/java/org/springframework/data/neo4j/core/mapping/CypherGenerator.java +++ b/src/main/java/org/springframework/data/neo4j/core/mapping/CypherGenerator.java @@ -16,13 +16,14 @@ package org.springframework.data.neo4j.core.mapping; import static org.neo4j.cypherdsl.core.Cypher.anyNode; +import static org.neo4j.cypherdsl.core.Cypher.coalesce; +import static org.neo4j.cypherdsl.core.Cypher.collect; import static org.neo4j.cypherdsl.core.Cypher.listBasedOn; import static org.neo4j.cypherdsl.core.Cypher.literalOf; import static org.neo4j.cypherdsl.core.Cypher.match; import static org.neo4j.cypherdsl.core.Cypher.node; import static org.neo4j.cypherdsl.core.Cypher.optionalMatch; import static org.neo4j.cypherdsl.core.Cypher.parameter; -import static org.neo4j.cypherdsl.core.Functions.coalesce; import java.util.ArrayList; import java.util.Arrays; @@ -39,11 +40,9 @@ import javax.lang.model.SourceVersion; import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Conditions; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Expression; import org.neo4j.cypherdsl.core.FunctionInvocation; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.IdentifiableElement; import org.neo4j.cypherdsl.core.MapProjection; import org.neo4j.cypherdsl.core.Named; @@ -87,9 +86,9 @@ public enum CypherGenerator { // default elementId function private Function elementIdOrIdFunction = named -> { if (named instanceof Node node) { - return Functions.elementId(node); + return Cypher.elementId(node); } else if (named instanceof Relationship relationship) { - return Functions.elementId(relationship); + return Cypher.elementId(relationship); } else { throw new IllegalArgumentException("Unsupported CypherDSL type: " + named.getClass()); } @@ -140,7 +139,8 @@ public enum CypherGenerator { List expressions = new ArrayList<>(); expressions.add(rootNode.getRequiredSymbolicName()); if (nodeDescription instanceof Neo4jPersistentEntity entity && entity.isUsingDeprecatedInternalId()) { - expressions.add(Functions.id(rootNode).as(Constants.NAME_OF_INTERNAL_ID)); + //noinspection deprecation + expressions.add(rootNode.internalId().as(Constants.NAME_OF_INTERNAL_ID)); } expressions.add(elementIdOrIdFunction.apply(rootNode).as(Constants.NAME_OF_ELEMENT_ID)); @@ -155,7 +155,7 @@ public enum CypherGenerator { StatementBuilder.OngoingReadingWithoutWhere match = prepareMatchOfRootNode(rootNode, initialMatchOn); List expressions = new ArrayList<>(); - expressions.add(Functions.collect(elementIdOrIdFunction.apply(rootNode)).as(Constants.NAME_OF_SYNTHESIZED_ROOT_NODE)); + expressions.add(Cypher.collect(elementIdOrIdFunction.apply(rootNode)).as(Constants.NAME_OF_SYNTHESIZED_ROOT_NODE)); return match .where(conditionOrNoCondition(condition)) @@ -192,9 +192,9 @@ public enum CypherGenerator { relationship = relationship.named(Constants.NAME_OF_SYNTHESIZED_RELATIONS); List expressions = new ArrayList<>(); - expressions.add(Functions.collect(elementIdOrIdFunction.apply(rootNode)).as(Constants.NAME_OF_SYNTHESIZED_ROOT_NODE)); - expressions.add(Functions.collect(elementIdOrIdFunction.apply(targetNode)).as(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES)); - expressions.add(Functions.collect(elementIdOrIdFunction.apply(relationship)).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS)); + expressions.add(Cypher.collect(elementIdOrIdFunction.apply(rootNode)).as(Constants.NAME_OF_SYNTHESIZED_ROOT_NODE)); + expressions.add(Cypher.collect(elementIdOrIdFunction.apply(targetNode)).as(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES)); + expressions.add(Cypher.collect(elementIdOrIdFunction.apply(relationship)).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS)); return match .where(conditionOrNoCondition(condition)) @@ -251,14 +251,14 @@ public enum CypherGenerator { versionCondition = rootNode.property(versionProperty.getName()) .isEqualTo(coalesce(parameter(Constants.NAME_OF_VERSION_PARAM), literalOf(0))); } else { - versionCondition = Conditions.noCondition(); + versionCondition = Cypher.noCondition(); } return match(rootNode) .where(idDescription.asIdExpression().isEqualTo(parameter(Constants.NAME_OF_ID))) .and(versionCondition).unwind(rootNode.labels()).as("label").with(Cypher.name("label")) .where(Cypher.name("label").in(parameter(Constants.NAME_OF_STATIC_LABELS_PARAM)).not()) - .returning(Functions.collect(Cypher.name("label")).as(Constants.NAME_OF_LABELS)).build(); + .returning(collect(Cypher.name("label")).as(Constants.NAME_OF_LABELS)).build(); } public Statement prepareDeleteOf(NodeDescription nodeDescription) { @@ -276,7 +276,7 @@ public enum CypherGenerator { .named(Constants.NAME_OF_TYPED_ROOT_NODE.apply(nodeDescription)); OngoingUpdate ongoingUpdate = match(rootNode).where(conditionOrNoCondition(condition)).detachDelete(rootNode); if (count) { - return ongoingUpdate.returning(Functions.count(rootNode)).build(); + return ongoingUpdate.returning(Cypher.count(rootNode)).build(); } return ongoingUpdate.build(); } @@ -289,7 +289,7 @@ public enum CypherGenerator { Neo4jPersistentProperty property = (Neo4jPersistentProperty) idProperty; - Condition result = Conditions.noCondition(); + Condition result = Cypher.noCondition(); for (String key : property.getOptionalConverter().write(null).keys()) { Property expression = Cypher.property(containerName, key); result = result.and(expression.isEqualTo(actualParameter.property(key))); @@ -420,7 +420,7 @@ public enum CypherGenerator { List expressions = new ArrayList<>(); if (nodeDescription instanceof Neo4jPersistentEntity entity && entity.isUsingDeprecatedInternalId()) { - Functions.id(rootNode).as(Constants.NAME_OF_INTERNAL_ID); + rootNode.internalId().as(Constants.NAME_OF_INTERNAL_ID); } expressions.add(elementIdOrIdFunction.apply(rootNode).as(Constants.NAME_OF_ELEMENT_ID)); expressions.add(rootNode.property(nameOfIdProperty).as(Constants.NAME_OF_ID)); @@ -465,9 +465,9 @@ public enum CypherGenerator { var idProperty = entity.getRequiredIdProperty(); if (entity.isUsingInternalIds()) { if (entity.isUsingDeprecatedInternalId() || !canUseElementId) { - startNodeIdFunction = Functions::id; + startNodeIdFunction = Node::internalId; } else { - startNodeIdFunction = Functions::elementId; + startNodeIdFunction = Cypher::elementId; } } else { startNodeIdFunction = node -> node.property(idProperty.getPropertyName()); @@ -479,25 +479,29 @@ public enum CypherGenerator { Function startNodeIdFunction; if (entity == null) { - return Functions::elementId; + return Cypher::elementId; } if (!entity.isUsingDeprecatedInternalId() && canUseElementId) { - startNodeIdFunction = Functions::elementId; + startNodeIdFunction = Cypher::elementId; } else { - startNodeIdFunction = Functions::id; + startNodeIdFunction = Node::internalId; } return startNodeIdFunction; } + static Expression relId(Relationship r) { + return FunctionInvocation.create(() -> "id", r.getRequiredSymbolicName()); + } + private static Function getRelationshipIdFunction(RelationshipDescription relationshipDescription, boolean canUseElementId) { - Function result = canUseElementId ? Functions::elementId : Functions::id; + Function result = canUseElementId ? Cypher::elementId : CypherGenerator::relId; if (relationshipDescription.hasRelationshipProperties()) { Neo4jPersistentEntity entity = (Neo4jPersistentEntity) relationshipDescription.getRelationshipPropertiesEntity(); if ((entity != null && entity.isUsingDeprecatedInternalId()) || !canUseElementId) { - result = Functions::id; + result = CypherGenerator::relId; } else { - result = Functions::elementId; + result = Cypher::elementId; } } return result; @@ -623,7 +627,7 @@ public enum CypherGenerator { private List getReturnedIdExpressionsForRelationship(RelationshipDescription relationship, Relationship relationshipFragment) { List result = new ArrayList<>(); if (relationship.hasRelationshipProperties() && relationship.getRelationshipPropertiesEntity() instanceof Neo4jPersistentEntity entity && entity.isUsingDeprecatedInternalId()) { - result.add(Functions.id(relationshipFragment).as(Constants.NAME_OF_INTERNAL_ID)); + result.add(relId(relationshipFragment).as(Constants.NAME_OF_INTERNAL_ID)); } result.add(elementIdOrIdFunction.apply(relationshipFragment).as(Constants.NAME_OF_ELEMENT_ID)); return result; @@ -661,7 +665,7 @@ public enum CypherGenerator { public Collection createReturnStatementForExists(Neo4jPersistentEntity nodeDescription) { - return Collections.singleton(Functions.count(Constants.NAME_OF_TYPED_ROOT_NODE.apply(nodeDescription))); + return Collections.singleton(Cypher.count(Constants.NAME_OF_TYPED_ROOT_NODE.apply(nodeDescription))); } public Collection createReturnStatementForMatch(Neo4jPersistentEntity nodeDescription) { @@ -711,7 +715,7 @@ public enum CypherGenerator { } } if (order.isIgnoreCase()) { - expression = Functions.toLower(expression); + expression = Cypher.toLower(expression); } return order.isAscending() ? expression.ascending() : expression.descending(); }).toArray(SortItem[]::new)) @@ -804,10 +808,11 @@ public enum CypherGenerator { } nodePropertiesProjection.add(Constants.NAME_OF_LABELS); - nodePropertiesProjection.add(Functions.labels(node)); + nodePropertiesProjection.add(Cypher.labels(node)); if (nodeDescription instanceof Neo4jPersistentEntity entity && entity.isUsingDeprecatedInternalId()) { nodePropertiesProjection.add(Constants.NAME_OF_INTERNAL_ID); - nodePropertiesProjection.add(Functions.id(node)); + //noinspection deprecation + nodePropertiesProjection.add(node.internalId()); } nodePropertiesProjection.add(Constants.NAME_OF_ELEMENT_ID); nodePropertiesProjection.add(elementIdOrIdFunction.apply(node)); @@ -876,7 +881,7 @@ public enum CypherGenerator { addMapProjection(relationshipTargetName, listBasedOn(relationship).returning(mapProjection - .and(RelationshipDescription.NAME_OF_RELATIONSHIP_TYPE, Functions.type(relationship))), + .and(RelationshipDescription.NAME_OF_RELATIONSHIP_TYPE, Cypher.type(relationship))), mapProjectionLists); } else { @@ -902,6 +907,6 @@ public enum CypherGenerator { } private static Condition conditionOrNoCondition(@Nullable Condition condition) { - return condition == null ? Conditions.noCondition() : condition; + return condition == null ? Cypher.noCondition() : condition; } } diff --git a/src/main/java/org/springframework/data/neo4j/core/mapping/IdDescription.java b/src/main/java/org/springframework/data/neo4j/core/mapping/IdDescription.java index e971f6d28..132eb2777 100644 --- a/src/main/java/org/springframework/data/neo4j/core/mapping/IdDescription.java +++ b/src/main/java/org/springframework/data/neo4j/core/mapping/IdDescription.java @@ -20,7 +20,6 @@ import java.util.Optional; import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Expression; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.SymbolicName; import org.springframework.data.neo4j.core.schema.GeneratedValue; @@ -99,7 +98,8 @@ public final class IdDescription { this.idExpression = Lazy.of(() -> { final Node rootNode = Cypher.anyNode(symbolicName); if (this.isInternallyGeneratedId()) { - return isDeprecated ? Functions.id(rootNode) : Functions.elementId(rootNode); + //noinspection deprecation + return isDeprecated ? rootNode.internalId() : rootNode.elementId(); } else { return this.getOptionalGraphPropertyName() .map(propertyName -> Cypher.property(symbolicName, propertyName)).get(); @@ -121,7 +121,8 @@ public final class IdDescription { public Expression asIdExpression(String nodeName) { final Node rootNode = Cypher.anyNode(nodeName); if (this.isInternallyGeneratedId()) { - return isDeprecated ? Functions.id(rootNode) : Functions.elementId(rootNode); + //noinspection deprecation + return isDeprecated ? rootNode.internalId() : rootNode.elementId(); } else { return this.getOptionalGraphPropertyName() .map(propertyName -> Cypher.property(nodeName, propertyName)).get(); diff --git a/src/main/java/org/springframework/data/neo4j/core/mapping/SpringDataCypherDsl.java b/src/main/java/org/springframework/data/neo4j/core/mapping/SpringDataCypherDsl.java index f9769f043..dcc84eae5 100644 --- a/src/main/java/org/springframework/data/neo4j/core/mapping/SpringDataCypherDsl.java +++ b/src/main/java/org/springframework/data/neo4j/core/mapping/SpringDataCypherDsl.java @@ -16,8 +16,8 @@ package org.springframework.data.neo4j.core.mapping; import org.apiguardian.api.API; +import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.FunctionInvocation; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Named; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.Relationship; @@ -39,14 +39,14 @@ public final class SpringDataCypherDsl { public static Function> elementIdOrIdFunction = dialect -> { if (dialect == Dialect.NEO4J_5) { return SpringDataCypherDsl::elementId; - } else if (dialect == Dialect.DEFAULT) { + } else if (dialect == Dialect.NEO4J_4) { return SpringDataCypherDsl::id; } else { return named -> { if (named instanceof Node node) { - return Functions.elementId(node); + return Cypher.elementId(node); } else if (named instanceof Relationship relationship) { - return Functions.elementId(relationship); + return Cypher.elementId(relationship); } else { throw new IllegalArgumentException("Unsupported CypherDSL type: " + named.getClass()); } diff --git a/src/main/java/org/springframework/data/neo4j/repository/query/CypherAdapterUtils.java b/src/main/java/org/springframework/data/neo4j/repository/query/CypherAdapterUtils.java index 336e95ed1..7d0f415f6 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/query/CypherAdapterUtils.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/CypherAdapterUtils.java @@ -27,10 +27,8 @@ import java.util.stream.Collectors; import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Conditions; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Expression; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.SortItem; import org.neo4j.cypherdsl.core.StatementBuilder; import org.neo4j.cypherdsl.core.SymbolicName; @@ -104,7 +102,7 @@ public final class CypherAdapterUtils { } else { expression = property(root, graphProperty.getPropertyName()); if (order.isIgnoreCase()) { - expression = Functions.toLower(expression); + expression = Cypher.toLower(expression); } } SortItem sortItem = Cypher.sort(expression); @@ -141,11 +139,11 @@ public final class CypherAdapterUtils { var root = Constants.NAME_OF_TYPED_ROOT_NODE.apply(entity); - var resultingCondition = Conditions.noCondition(); + var resultingCondition = Cypher.noCondition(); // This is the next equality pair if previous sort key was equal - var nextEquals = Conditions.noCondition(); + var nextEquals = Cypher.noCondition(); // This is the condition for when all the sort orderedKeys are equal, and we must filter via id - var allEqualsWithArtificialSort = Conditions.noCondition(); + var allEqualsWithArtificialSort = Cypher.noCondition(); for (Map.Entry entry : orderedKeys.entrySet()) { diff --git a/src/main/java/org/springframework/data/neo4j/repository/query/CypherQueryCreator.java b/src/main/java/org/springframework/data/neo4j/repository/query/CypherQueryCreator.java index d90b0f0bf..98585bb46 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/query/CypherQueryCreator.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/CypherQueryCreator.java @@ -15,7 +15,7 @@ */ package org.springframework.data.neo4j.repository.query; -import static org.neo4j.cypherdsl.core.Functions.point; +import static org.neo4j.cypherdsl.core.Cypher.point; import java.util.ArrayList; import java.util.Collection; @@ -33,13 +33,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Conditions; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Expression; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.PatternElement; -import org.neo4j.cypherdsl.core.Predicates; import org.neo4j.cypherdsl.core.Property; import org.neo4j.cypherdsl.core.RelationshipPattern; import org.neo4j.cypherdsl.core.SortItem; @@ -202,7 +199,7 @@ final class CypherQueryCreator extends AbstractQueryCreator relationshipChain = new ArrayList<>(); for (PropertyPathWrapper possiblePathWithRelationship : propertyPathWrappers) { @@ -219,12 +216,12 @@ final class CypherQueryCreator extends AbstractQueryCreator) property.getOwner())), toCypherParameter(nextRequiredParameter(actualParameters, property), ignoreCase)); if (part.getType() == Part.Type.NEGATING_SIMPLE_PROPERTY) { - compositePropertyCondition = Conditions.not(compositePropertyCondition); + compositePropertyCondition = Cypher.not(compositePropertyCondition); } return compositePropertyCondition; } @@ -291,7 +288,7 @@ final class CypherQueryCreator extends AbstractQueryCreator containingCondition(path, property, actualParameters, ignoreCase); case ENDING_WITH -> toCypherProperty(path, ignoreCase) .endsWith(toCypherParameter(nextRequiredParameter(actualParameters, property), ignoreCase)); - case EXISTS -> Predicates.exists(toCypherProperty(property)); + case EXISTS -> Cypher.exists(toCypherProperty(property)); case FALSE -> toCypherProperty(path, ignoreCase).isFalse(); case GREATER_THAN_EQUAL -> toCypherProperty(path, ignoreCase) .gte(toCypherParameter(nextRequiredParameter(actualParameters, property), ignoreCase)); @@ -333,7 +330,7 @@ final class CypherQueryCreator extends AbstractQueryCreator owner = (Neo4jPersistentEntity) leafProperty.getOwner(); String containerName = getContainerName(path, owner); return toCypherParameter(nextRequiredParameter(actualParameters, property), ignoreCase) - .in(Functions.labels(Cypher.anyNode(containerName))); + .in(Cypher.labels(Cypher.anyNode(containerName))); } if (property.isCollectionLike()) { return toCypherParameter(nextRequiredParameter(actualParameters, property), ignoreCase).in(cypherProperty); @@ -401,7 +398,7 @@ final class CypherQueryCreator extends AbstractQueryCreator p.hasValueOfType(Distance.class)).isPresent()) { return distanceFunction.lte(toCypherParameter(other.get(), false)); @@ -414,7 +411,7 @@ final class CypherQueryCreator extends AbstractQueryCreator implements CypherdslConditi return this.neo4jOperations.toExecutableQuery( this.metaData.getType(), - QueryFragmentsAndParameters.forConditionAndSortItems(this.metaData, Conditions.noCondition(), Arrays.asList(sortItems)) + QueryFragmentsAndParameters.forConditionAndSortItems(this.metaData, Cypher.noCondition(), Arrays.asList(sortItems)) ).getResults(); } @@ -129,7 +128,7 @@ public final class CypherdslConditionExecutorImpl implements CypherdslConditi public long count(Condition condition) { Statement statement = CypherGenerator.INSTANCE.prepareMatchOf(this.metaData, condition) - .returning(Functions.count(asterisk())).build(); + .returning(Cypher.count(asterisk())).build(); return this.neo4jOperations.count(statement, statement.getCatalog().getParameters()); } diff --git a/src/main/java/org/springframework/data/neo4j/repository/query/Predicate.java b/src/main/java/org/springframework/data/neo4j/repository/query/Predicate.java index e9d3ee701..b7304d500 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/query/Predicate.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/Predicate.java @@ -30,9 +30,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiFunction; import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Conditions; +import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Expression; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.StatementBuilder; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; @@ -177,8 +176,8 @@ final class Predicate { if (String.class.equals(graphProperty.getActualType())) { if (matcherAccessor.isIgnoreCaseForPath(currentPath)) { - property = Functions.toLower(property); - parameter = Functions.toLower(parameter); + property = Cypher.toLower(property); + parameter = Cypher.toLower(parameter); } condition = switch (matcherAccessor.getStringMatcherForPath(currentPath)) { @@ -206,7 +205,7 @@ final class Predicate { private final Neo4jPersistentEntity neo4jPersistentEntity; - private Condition condition = Conditions.noCondition(); + private Condition condition = Cypher.noCondition(); private final Map parameters = new HashMap<>(); diff --git a/src/main/java/org/springframework/data/neo4j/repository/query/QueryFragments.java b/src/main/java/org/springframework/data/neo4j/repository/query/QueryFragments.java index 914cdd675..27231d01d 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/query/QueryFragments.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/QueryFragments.java @@ -25,7 +25,6 @@ import java.util.function.Predicate; import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Conditions; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Expression; import org.neo4j.cypherdsl.core.PatternElement; @@ -77,7 +76,7 @@ public final class QueryFragments { } public void setCondition(@Nullable Condition condition) { - this.condition = Optional.ofNullable(condition).orElse(Conditions.noCondition()); + this.condition = Optional.ofNullable(condition).orElse(Cypher.noCondition()); } public Condition getCondition() { diff --git a/src/main/java/org/springframework/data/neo4j/repository/query/QueryFragmentsAndParameters.java b/src/main/java/org/springframework/data/neo4j/repository/query/QueryFragmentsAndParameters.java index ae732ea85..051c1f2db 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/query/QueryFragmentsAndParameters.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/QueryFragmentsAndParameters.java @@ -17,7 +17,6 @@ package org.springframework.data.neo4j.repository.query; import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Conditions; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.PatternElement; @@ -152,7 +151,7 @@ public final class QueryFragmentsAndParameters { public static QueryFragmentsAndParameters forFindAll(Neo4jPersistentEntity entityMetaData) { QueryFragments queryFragments = new QueryFragments(); queryFragments.addMatchOn(cypherGenerator.createRootNode(entityMetaData)); - queryFragments.setCondition(Conditions.noCondition()); + queryFragments.setCondition(Cypher.noCondition()); queryFragments.setReturnExpressions(cypherGenerator.createReturnStatementForMatch(entityMetaData)); return new QueryFragmentsAndParameters(entityMetaData, queryFragments, Collections.emptyMap(), null); } diff --git a/src/main/java/org/springframework/data/neo4j/repository/query/ReactiveCypherdslConditionExecutorImpl.java b/src/main/java/org/springframework/data/neo4j/repository/query/ReactiveCypherdslConditionExecutorImpl.java index 1e5d67dfe..e3d363abf 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/query/ReactiveCypherdslConditionExecutorImpl.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/ReactiveCypherdslConditionExecutorImpl.java @@ -22,8 +22,7 @@ import java.util.function.Predicate; import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Conditions; -import org.neo4j.cypherdsl.core.Functions; +import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.SortItem; import org.neo4j.cypherdsl.core.Statement; import org.springframework.data.domain.Sort; @@ -106,7 +105,7 @@ public final class ReactiveCypherdslConditionExecutorImpl implements Reactive return this.neo4jOperations.toExecutableQuery( this.metaData.getType(), - QueryFragmentsAndParameters.forConditionAndSortItems(this.metaData, Conditions.noCondition(), + QueryFragmentsAndParameters.forConditionAndSortItems(this.metaData, Cypher.noCondition(), Arrays.asList(sortItems)) ).flatMapMany(ReactiveNeo4jOperations.ExecutableQuery::getResults); } @@ -115,7 +114,7 @@ public final class ReactiveCypherdslConditionExecutorImpl implements Reactive public Mono count(Condition condition) { Statement statement = CypherGenerator.INSTANCE.prepareMatchOf(this.metaData, condition) - .returning(Functions.count(asterisk())).build(); + .returning(Cypher.count(asterisk())).build(); return this.neo4jOperations.count(statement, statement.getCatalog().getParameters()); } diff --git a/src/main/java/org/springframework/data/neo4j/repository/query/ReactiveQuerydslNeo4jPredicateExecutor.java b/src/main/java/org/springframework/data/neo4j/repository/query/ReactiveQuerydslNeo4jPredicateExecutor.java index a13b7d5c8..8e15c8dce 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/query/ReactiveQuerydslNeo4jPredicateExecutor.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/ReactiveQuerydslNeo4jPredicateExecutor.java @@ -27,9 +27,7 @@ import java.util.function.Function; import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Conditions; import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.SortItem; import org.neo4j.cypherdsl.core.Statement; import org.reactivestreams.Publisher; @@ -108,7 +106,7 @@ public final class ReactiveQuerydslNeo4jPredicateExecutor implements Reactive @Override public Flux findAll(OrderSpecifier... orders) { - return doFindAll(Conditions.noCondition(), Arrays.asList(QuerydslNeo4jPredicateExecutor.toSortItems(orders))); + return doFindAll(Cypher.noCondition(), Arrays.asList(QuerydslNeo4jPredicateExecutor.toSortItems(orders))); } private Flux doFindAll(Condition condition, Collection sortItems) { @@ -124,7 +122,7 @@ public final class ReactiveQuerydslNeo4jPredicateExecutor implements Reactive Statement statement = CypherGenerator.INSTANCE.prepareMatchOf(this.metaData, Cypher.adapt(predicate).asCondition()) - .returning(Functions.count(asterisk())).build(); + .returning(Cypher.count(asterisk())).build(); return this.neo4jOperations.count(statement, statement.getCatalog().getParameters()); } diff --git a/src/main/java/org/springframework/data/neo4j/repository/query/SimpleQueryByExampleExecutor.java b/src/main/java/org/springframework/data/neo4j/repository/query/SimpleQueryByExampleExecutor.java index d6c4f3321..350f0a33b 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/query/SimpleQueryByExampleExecutor.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/SimpleQueryByExampleExecutor.java @@ -16,7 +16,8 @@ package org.springframework.data.neo4j.repository.query; import org.apiguardian.api.API; -import org.neo4j.cypherdsl.core.Functions; + +import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Statement; import org.springframework.data.domain.Example; import org.springframework.data.domain.Page; @@ -95,7 +96,7 @@ public final class SimpleQueryByExampleExecutor implements QueryByExampleExec Predicate predicate = Predicate.create(mappingContext, example); Statement statement = predicate.useWithReadingFragment(cypherGenerator::prepareMatchOf) - .returning(Functions.count(asterisk())).build(); + .returning(Cypher.count(asterisk())).build(); return this.neo4jOperations.count(statement, predicate.getParameters()); } @@ -105,7 +106,7 @@ public final class SimpleQueryByExampleExecutor implements QueryByExampleExec Predicate predicate = Predicate.create(mappingContext, example); Statement statement = predicate.useWithReadingFragment(cypherGenerator::prepareMatchOf) - .returning(Functions.count(asterisk())).build(); + .returning(Cypher.count(asterisk())).build(); return this.neo4jOperations.count(statement, predicate.getParameters()) > 0; } diff --git a/src/main/java/org/springframework/data/neo4j/repository/query/SimpleReactiveQueryByExampleExecutor.java b/src/main/java/org/springframework/data/neo4j/repository/query/SimpleReactiveQueryByExampleExecutor.java index 4ac04e144..4867f28b8 100644 --- a/src/main/java/org/springframework/data/neo4j/repository/query/SimpleReactiveQueryByExampleExecutor.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/SimpleReactiveQueryByExampleExecutor.java @@ -16,7 +16,8 @@ package org.springframework.data.neo4j.repository.query; import org.apiguardian.api.API; -import org.neo4j.cypherdsl.core.Functions; + +import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Statement; import org.reactivestreams.Publisher; import org.springframework.data.domain.Example; @@ -85,7 +86,7 @@ public final class SimpleReactiveQueryByExampleExecutor implements ReactiveQu Predicate predicate = Predicate.create(mappingContext, example); Statement statement = predicate.useWithReadingFragment(cypherGenerator::prepareMatchOf) - .returning(Functions.count(asterisk())).build(); + .returning(Cypher.count(asterisk())).build(); return this.neo4jOperations.count(statement, predicate.getParameters()); } diff --git a/src/test/java/org/springframework/data/neo4j/documentation/repositories/custom_queries/MovieRepository.java b/src/test/java/org/springframework/data/neo4j/documentation/repositories/custom_queries/MovieRepository.java index 303e24f5b..de9166ce2 100644 --- a/src/test/java/org/springframework/data/neo4j/documentation/repositories/custom_queries/MovieRepository.java +++ b/src/test/java/org/springframework/data/neo4j/documentation/repositories/custom_queries/MovieRepository.java @@ -31,7 +31,6 @@ import java.util.Map; // tag::domain-results-impl[] import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; // end::domain-results-impl[] @@ -89,7 +88,7 @@ class DomainResultsImpl implements DomainResults { var p = shortestPath.getRequiredSymbolicName(); var statement = Cypher.match(shortestPath) .with(p, listWith(name("n")) - .in(Functions.nodes(shortestPath)) + .in(Cypher.nodes(shortestPath)) .where(anyNode().named("n").hasLabels("Movie")).returning().as("mn") ) .unwind(name("mn")).as("m") @@ -97,7 +96,7 @@ class DomainResultsImpl implements DomainResults { .match(node("Person").named("d") .relationshipTo(anyNode("m"), "DIRECTED").named("r") ) - .returning(p, Functions.collect(name("r")), Functions.collect(name("d"))) + .returning(p, Cypher.collect(name("r")), Cypher.collect(name("d"))) .build(); Map parameters = new HashMap<>(); diff --git a/src/test/java/org/springframework/data/neo4j/integration/cdi/Neo4jCdiExtensionIT.java b/src/test/java/org/springframework/data/neo4j/integration/cdi/Neo4jCdiExtensionIT.java index 4e00efac5..d056ec836 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/cdi/Neo4jCdiExtensionIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/cdi/Neo4jCdiExtensionIT.java @@ -65,7 +65,7 @@ class Neo4jCdiExtensionIT { return Configuration.newConfig().withDialect(Dialect.NEO4J_5).build(); } - return Configuration.newConfig().withDialect(Dialect.DEFAULT).build(); + return Configuration.newConfig().withDialect(Dialect.NEO4J_4).build(); } } diff --git a/src/test/java/org/springframework/data/neo4j/integration/imperative/CypherdslStatementExecutorIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/CypherdslStatementExecutorIT.java index 6dd657544..1fd3e870f 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/imperative/CypherdslStatementExecutorIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/CypherdslStatementExecutorIT.java @@ -22,7 +22,6 @@ import java.util.Optional; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.Relationship; import org.neo4j.cypherdsl.core.Statement; @@ -86,8 +85,8 @@ class CypherdslStatementExecutorIT { .where(p.property("firstName").isEqualTo(Cypher.anonParameter(name))) // <.> .returning( p.getRequiredSymbolicName(), - Functions.collect(r), - Functions.collect(a) + Cypher.collect(r), + Cypher.collect(a) ) .build(); } @@ -100,8 +99,8 @@ class CypherdslStatementExecutorIT { return Cypher.match(p).optionalMatch(r) .returning( p.getRequiredSymbolicName(), - Functions.collect(r), - Functions.collect(a) + Cypher.collect(r), + Cypher.collect(a) ) .orderBy(p.property("firstName").ascending()) .build(); @@ -114,8 +113,8 @@ class CypherdslStatementExecutorIT { return Cypher.match(p).optionalMatch(r) .returning( p.getRequiredSymbolicName(), - Functions.collect(r), - Functions.collect(a) + Cypher.collect(r), + Cypher.collect(a) ); } @@ -193,7 +192,7 @@ class CypherdslStatementExecutorIT { Node person = Cypher.node("Person"); Page result = repository.findAll( - byCustomQueryWithoutOrder(), Cypher.match(person).returning(Functions.count(person)).build(), + byCustomQueryWithoutOrder(), Cypher.match(person).returning(Cypher.count(person)).build(), PageRequest.of(1, 2, Sort.by("p.firstName").ascending()) ); @@ -209,7 +208,7 @@ class CypherdslStatementExecutorIT { Node person = Cypher.node("Person"); Page result = repository.findAll( - byCustomQueryWithoutOrder(), Cypher.match(person).returning(Functions.count(person)).build(), + byCustomQueryWithoutOrder(), Cypher.match(person).returning(Cypher.count(person)).build(), PageRequest.of(1, 2, Sort.by("p.firstName").ascending()), NamesOnly.class ); diff --git a/src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicLabelsIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicLabelsIT.java index 807f2f447..9bba2a4cd 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicLabelsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicLabelsIT.java @@ -31,7 +31,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.neo4j.cypherdsl.core.Condition; import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.renderer.Renderer; import org.neo4j.driver.Driver; @@ -508,7 +507,7 @@ public class DynamicLabelsIT { } protected final List getLabels(Long id) { - return getLabels(Functions.id(Cypher.anyNode().named("n")).isEqualTo(parameter("id")), id); + return getLabels(Cypher.anyNode().named("n").internalId().isEqualTo(parameter("id")), id); } protected final List getLabels(Condition idCondition, Object id) { diff --git a/src/test/java/org/springframework/data/neo4j/integration/imperative/Neo4jTemplateIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/Neo4jTemplateIT.java index abd670f83..8a66b0643 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/imperative/Neo4jTemplateIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/Neo4jTemplateIT.java @@ -18,7 +18,6 @@ package org.springframework.data.neo4j.integration.imperative; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.Statement; import org.neo4j.driver.Driver; @@ -130,7 +129,7 @@ class Neo4jTemplateIT { @Test void countWithStatement() { Node node = Cypher.node("PersonWithAllConstructor").named("n"); - Statement statement = Cypher.match(node).returning(Functions.count(node)).build(); + Statement statement = Cypher.match(node).returning(Cypher.count(node)).build(); assertThat(neo4jTemplate.count(statement)).isEqualTo(2); } @@ -139,7 +138,7 @@ class Neo4jTemplateIT { void countWithStatementAndParameters() { Node node = Cypher.node("PersonWithAllConstructor").named("n"); Statement statement = Cypher.match(node).where(node.property("name").isEqualTo(Cypher.parameter("name"))) - .returning(Functions.count(node)).build(); + .returning(Cypher.count(node)).build(); assertThat(neo4jTemplate.count(statement, Collections.singletonMap("name", TEST_PERSON1_NAME))).isEqualTo(1); } diff --git a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCypherdslStatementExecutorIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCypherdslStatementExecutorIT.java index 37c965889..dffadc48a 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCypherdslStatementExecutorIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCypherdslStatementExecutorIT.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.Property; import org.neo4j.cypherdsl.core.Relationship; @@ -102,8 +101,8 @@ class ReactiveCypherdslStatementExecutorIT { .where(p.property("firstName").isEqualTo(Cypher.anonParameter(name))) .returning( p.getRequiredSymbolicName(), - Functions.collect(r), - Functions.collect(a) + Cypher.collect(r), + Cypher.collect(a) ) .build(); } @@ -115,8 +114,8 @@ class ReactiveCypherdslStatementExecutorIT { return Cypher.match(p).optionalMatch(r) .returning( p.getRequiredSymbolicName(), - Functions.collect(r), - Functions.collect(a) + Cypher.collect(r), + Cypher.collect(a) ) .orderBy(p.property("firstName").ascending()) .build(); @@ -129,8 +128,8 @@ class ReactiveCypherdslStatementExecutorIT { return Cypher.match(p).optionalMatch(r) .returning( p.getRequiredSymbolicName(), - Functions.collect(r), - Functions.collect(a) + Cypher.collect(r), + Cypher.collect(a) ); } diff --git a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicLabelsIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicLabelsIT.java index 1255c4cf5..1419068bd 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicLabelsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicLabelsIT.java @@ -17,7 +17,6 @@ package org.springframework.data.neo4j.integration.reactive; import static org.assertj.core.api.Assertions.assertThat; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.driver.TransactionContext; import org.junit.jupiter.api.RepeatedTest; import org.neo4j.driver.reactive.ReactiveSession; @@ -471,8 +470,9 @@ public class ReactiveDynamicLabelsIT { } } + @SuppressWarnings("deprecation") protected final Flux getLabels(Long id) { - return getLabels(Functions.id(Cypher.anyNode().named("n")).isEqualTo(Cypher.parameter("id")), id); + return getLabels(Cypher.anyNode().named("n").internalId().isEqualTo(Cypher.parameter("id")), id); } protected final Flux getLabels(Condition idCondition, Object id) { diff --git a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jClientIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jClientIT.java index 98b69601c..b5dbab763 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jClientIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jClientIT.java @@ -261,17 +261,17 @@ class ReactiveNeo4jClientIT { } Query createQuery() { - return new Query(this.delegate.getCypher(), this.delegate.getParameters()); + return new Query(this.delegate.getCypher(), this.delegate.getCatalog().getParameters()); } @Override public Map getParameters() { - return this.delegate.getParameters(); + return this.delegate.getCatalog().getParameters(); } @Override public Collection getParameterNames() { - return this.delegate.getParameterNames(); + return this.delegate.getCatalog().getParameterNames(); } @Override diff --git a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jTemplateIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jTemplateIT.java index 63bafad7d..de05a2cca 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jTemplateIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jTemplateIT.java @@ -19,7 +19,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.Statement; import org.neo4j.driver.Driver; @@ -150,7 +149,7 @@ class ReactiveNeo4jTemplateIT { @Test void countWithStatement() { Node node = Cypher.node("PersonWithAllConstructor").named("n"); - Statement statement = Cypher.match(node).returning(Functions.count(node)).build(); + Statement statement = Cypher.match(node).returning(Cypher.count(node)).build(); StepVerifier.create(neo4jTemplate.count(statement)).assertNext(count -> assertThat(count).isEqualTo(2)) .verifyComplete(); @@ -160,7 +159,7 @@ class ReactiveNeo4jTemplateIT { void countWithStatementAndParameters() { Node node = Cypher.node("PersonWithAllConstructor").named("n"); Statement statement = Cypher.match(node).where(node.property("name").isEqualTo(parameter("name"))) - .returning(Functions.count(node)).build(); + .returning(Cypher.count(node)).build(); StepVerifier.create(neo4jTemplate.count(statement, Collections.singletonMap("name", TEST_PERSON1_NAME))) .assertNext(count -> assertThat(count).isEqualTo(1)).verifyComplete(); diff --git a/src/test/java/org/springframework/data/neo4j/integration/versioned_self_references/TestBase.java b/src/test/java/org/springframework/data/neo4j/integration/versioned_self_references/TestBase.java index edde95e80..6ecf704c7 100644 --- a/src/test/java/org/springframework/data/neo4j/integration/versioned_self_references/TestBase.java +++ b/src/test/java/org/springframework/data/neo4j/integration/versioned_self_references/TestBase.java @@ -31,7 +31,7 @@ import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.params.provider.Arguments; import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; + import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.ResultStatement; import org.neo4j.cypherdsl.core.executables.ExecutableStatement; @@ -136,7 +136,8 @@ abstract class TestBase { if (isExternal) { statement = Cypher.create(nodeTemplate).returning(nodeTemplate.property("id")).build(); } else { - statement = Cypher.create(nodeTemplate).returning(Functions.id(nodeTemplate)).build(); + //noinspection deprecation + statement = Cypher.create(nodeTemplate).returning(nodeTemplate.internalId()).build(); } long id = ExecutableStatement.makeExecutable(statement).fetchWith(tx).get(0).get(0).asLong(); @@ -173,10 +174,11 @@ abstract class TestBase { .returning(n1.property("id"), n2.property("id")) .build(); } else { + //noinspection deprecation statement = Cypher.create(n1).create(n2) .merge(n1.relationshipTo(n2, "RELATED")) .merge(n2.relationshipTo(n1, "RELATED")) - .returning(Functions.id(n1), Functions.id(n2)) + .returning(n1.internalId(), n2.internalId()) .build(); } @@ -257,9 +259,9 @@ abstract class TestBase { Node nodeTemplate = Cypher.node(type.getSimpleName()); Node n1 = nodeTemplate.named("n1"); Node n2 = nodeTemplate.named("n2"); - ResultStatement statement = + @SuppressWarnings("deprecation") ResultStatement statement = Cypher.match(n1.relationshipTo(n2, "RELATED")) - .where(Functions.id(n1).isEqualTo(Cypher.anonParameter(id)) + .where(n1.internalId().isEqualTo(Cypher.anonParameter(id)) .and(n2.relationshipTo(n1, "RELATED"))) .returning(n1.property("version")).build();