2
pom.xml
2
pom.xml
@@ -77,7 +77,7 @@
|
||||
<checkstyle.skip>${skipTests}</checkstyle.skip>
|
||||
<checkstyle.version>8.40</checkstyle.version>
|
||||
<classgraph.version>4.8.149</classgraph.version>
|
||||
<cypher-dsl.version>2022.6.0</cypher-dsl.version>
|
||||
<cypher-dsl.version>2023.0.0</cypher-dsl.version>
|
||||
<dist.id>spring-data-neo4j</dist.id>
|
||||
<dist.key>SDNEO4J</dist.key>
|
||||
<flatten-maven-plugin.version>1.2.5</flatten-maven-plugin.version>
|
||||
|
||||
@@ -211,17 +211,17 @@ public final class TemplateSupport {
|
||||
.with(Functions.collect(rootNodes).as(Constants.NAME_OF_ROOT_NODE))
|
||||
.optionalMatch(relationships)
|
||||
.where(Functions.id(relationships).in(Cypher.parameter(relationshipIds)))
|
||||
.with(Constants.NAME_OF_ROOT_NODE, Functions.collectDistinct(relationships).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS).asExpression())
|
||||
.with(Constants.NAME_OF_ROOT_NODE, Functions.collectDistinct(relationships).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS))
|
||||
.optionalMatch(relatedNodes)
|
||||
.where(Functions.id(relatedNodes).in(Cypher.parameter(relatedNodeIds)))
|
||||
.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).asExpression()
|
||||
Functions.collectDistinct(relatedNodes).as(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES)
|
||||
)
|
||||
.unwind(Constants.NAME_OF_ROOT_NODE).as(rootNodeIds)
|
||||
.with(
|
||||
Cypher.name(rootNodeIds).as(Constants.NAME_OF_TYPED_ROOT_NODE.apply(nodeDescription).getValue()).asExpression(),
|
||||
Cypher.name(rootNodeIds).as(Constants.NAME_OF_TYPED_ROOT_NODE.apply(nodeDescription).getValue()),
|
||||
Cypher.name(Constants.NAME_OF_SYNTHESIZED_RELATIONS),
|
||||
Cypher.name(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES))
|
||||
.orderBy(queryFragments.getOrderBy())
|
||||
|
||||
@@ -34,6 +34,8 @@ import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
import org.apiguardian.api.API;
|
||||
import org.neo4j.cypherdsl.core.Condition;
|
||||
import org.neo4j.cypherdsl.core.Conditions;
|
||||
@@ -41,6 +43,7 @@ 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.Node;
|
||||
import org.neo4j.cypherdsl.core.Parameter;
|
||||
@@ -55,6 +58,7 @@ import org.neo4j.cypherdsl.core.StatementBuilder.OngoingUpdate;
|
||||
import org.neo4j.cypherdsl.core.SymbolicName;
|
||||
import org.neo4j.cypherdsl.core.renderer.Configuration;
|
||||
import org.neo4j.cypherdsl.core.renderer.Renderer;
|
||||
import org.neo4j.cypherdsl.core.utils.Assertions;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mapping.MappingException;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
@@ -111,12 +115,12 @@ public enum CypherGenerator {
|
||||
|
||||
Node rootNode = createRootNode(nodeDescription);
|
||||
|
||||
List<Expression> expressions = new ArrayList<>();
|
||||
List<IdentifiableElement> expressions = new ArrayList<>();
|
||||
expressions.add(rootNode.getRequiredSymbolicName());
|
||||
expressions.add(Functions.id(rootNode).as(Constants.NAME_OF_INTERNAL_ID));
|
||||
expressions.add(Functions.elementId(rootNode).as(Constants.NAME_OF_ELEMENT_ID));
|
||||
|
||||
return match(rootNode).where(conditionOrNoCondition(condition)).with(expressions.toArray(new Expression[] {}));
|
||||
return match(rootNode).where(conditionOrNoCondition(condition)).with(expressions.toArray(IdentifiableElement[]::new));
|
||||
}
|
||||
|
||||
public StatementBuilder.OngoingReading prepareMatchOf(NodeDescription<?> nodeDescription,
|
||||
@@ -126,12 +130,12 @@ public enum CypherGenerator {
|
||||
|
||||
StatementBuilder.OngoingReadingWithoutWhere match = prepareMatchOfRootNode(rootNode, initialMatchOn);
|
||||
|
||||
List<Expression> expressions = new ArrayList<>();
|
||||
List<IdentifiableElement> expressions = new ArrayList<>();
|
||||
expressions.add(Functions.collect(Functions.id(rootNode)).as(Constants.NAME_OF_SYNTHESIZED_ROOT_NODE));
|
||||
|
||||
return match
|
||||
.where(conditionOrNoCondition(condition))
|
||||
.with(expressions.toArray(new Expression[]{}));
|
||||
.with(expressions.toArray(IdentifiableElement[]::new));
|
||||
}
|
||||
|
||||
public StatementBuilder.OngoingReading prepareMatchOf(NodeDescription<?> nodeDescription,
|
||||
@@ -163,7 +167,7 @@ public enum CypherGenerator {
|
||||
};
|
||||
|
||||
relationship = relationship.named(Constants.NAME_OF_SYNTHESIZED_RELATIONS);
|
||||
List<Expression> expressions = new ArrayList<>();
|
||||
List<IdentifiableElement> expressions = new ArrayList<>();
|
||||
expressions.add(Functions.collect(Functions.id(rootNode)).as(Constants.NAME_OF_SYNTHESIZED_ROOT_NODE));
|
||||
expressions.add(Functions.collect(Functions.id(targetNode)).as(Constants.NAME_OF_SYNTHESIZED_RELATED_NODES));
|
||||
expressions.add(Functions.collect(Functions.id(relationship)).as(Constants.NAME_OF_SYNTHESIZED_RELATIONS));
|
||||
@@ -171,7 +175,7 @@ public enum CypherGenerator {
|
||||
return match
|
||||
.where(conditionOrNoCondition(condition))
|
||||
.optionalMatch(relationship)
|
||||
.with(expressions.toArray(new Expression[]{}));
|
||||
.with(expressions.toArray(IdentifiableElement[]::new));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -619,6 +623,7 @@ public enum CypherGenerator {
|
||||
expression = Cypher.property(property.substring(0, firstDot), tail);
|
||||
} else {
|
||||
try {
|
||||
Assertions.isTrue(SourceVersion.isIdentifier(property), "Name must be a valid identifier.");
|
||||
expression = Cypher.name(property);
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (e.getMessage().endsWith(".")) {
|
||||
|
||||
@@ -31,11 +31,7 @@ import java.util.Map;
|
||||
|
||||
// tag::domain-results-impl[]
|
||||
import org.neo4j.cypherdsl.core.Cypher;
|
||||
import org.neo4j.cypherdsl.core.Expression;
|
||||
import org.neo4j.cypherdsl.core.Functions;
|
||||
import org.neo4j.cypherdsl.core.NamedPath;
|
||||
import org.neo4j.cypherdsl.core.Node;
|
||||
import org.neo4j.cypherdsl.core.Statement;
|
||||
|
||||
// end::domain-results-impl[]
|
||||
|
||||
@@ -85,13 +81,13 @@ class DomainResultsImpl implements DomainResults {
|
||||
@Override
|
||||
public List<MovieEntity> findMoviesAlongShortestPath(PersonEntity from, PersonEntity to) {
|
||||
|
||||
Node p1 = node("Person").withProperties("name", parameter("person1"));
|
||||
Node p2 = node("Person").withProperties("name", parameter("person2"));
|
||||
NamedPath shortestPath = shortestPath("p").definedBy(
|
||||
var p1 = node("Person").withProperties("name", parameter("person1"));
|
||||
var p2 = node("Person").withProperties("name", parameter("person2"));
|
||||
var shortestPath = shortestPath("p").definedBy(
|
||||
p1.relationshipBetween(p2).unbounded()
|
||||
);
|
||||
Expression p = shortestPath.getRequiredSymbolicName();
|
||||
Statement statement = Cypher.match(shortestPath)
|
||||
var p = shortestPath.getRequiredSymbolicName();
|
||||
var statement = Cypher.match(shortestPath)
|
||||
.with(p, listWith(name("n"))
|
||||
.in(Functions.nodes(shortestPath))
|
||||
.where(anyNode().named("n").hasLabels("Movie")).returning().as("mn")
|
||||
|
||||
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import org.neo4j.cypherdsl.core.Statement;
|
||||
import org.neo4j.cypherdsl.core.executables.ExecutableResultStatement;
|
||||
import org.neo4j.driver.Query;
|
||||
import org.neo4j.driver.QueryRunner;
|
||||
import org.neo4j.driver.Record;
|
||||
import org.neo4j.driver.SimpleQueryRunner;
|
||||
import org.neo4j.driver.async.AsyncQueryRunner;
|
||||
import org.neo4j.driver.reactivestreams.ReactiveQueryRunner;
|
||||
import org.neo4j.driver.reactivestreams.ReactiveResult;
|
||||
@@ -176,7 +176,7 @@ class ReactiveNeo4jClientIT {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> fetchWith(QueryRunner queryRunner, Function<Record, T> function) {
|
||||
public <T> List<T> fetchWith(SimpleQueryRunner queryRunner, Function<Record, T> function) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -186,12 +186,12 @@ class ReactiveNeo4jClientIT {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSummary streamWith(QueryRunner queryRunner, Consumer<Stream<Record>> consumer) {
|
||||
public ResultSummary streamWith(SimpleQueryRunner queryRunner, Consumer<Stream<Record>> consumer) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSummary executeWith(QueryRunner queryRunner) {
|
||||
public ResultSummary executeWith(SimpleQueryRunner queryRunner) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user