Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-dsl-schema-name-support</artifactId>
<version>${cypher-dsl.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
Expand Down Expand Up @@ -370,6 +375,10 @@
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-dsl</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-dsl-schema-name-support</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
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;
Expand Down Expand Up @@ -701,7 +700,7 @@ public Collection<Expression> createReturnStatementForMatch(Neo4jPersistentEntit
expression = Cypher.property(property.substring(0, firstDot), tail);
} else {
try {
Assertions.isTrue(SourceVersion.isIdentifier(property), "Name must be a valid identifier.");
Assert.isTrue(SourceVersion.isIdentifier(property), "Name must be a valid identifier.");
expression = Cypher.name(property);
} catch (IllegalArgumentException e) {
if (e.getMessage().endsWith(".")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.neo4j.driver.Record;
import org.neo4j.driver.Value;
import org.neo4j.driver.Values;
import org.neo4j.driver.internal.value.NullValue;
import org.neo4j.driver.types.MapAccessor;
import org.neo4j.driver.types.Node;
import org.neo4j.driver.types.Relationship;
Expand Down Expand Up @@ -895,7 +894,7 @@ private static Value extractValueOf(Neo4jPersistentProperty property, MapAccesso
} else if (propertyContainer.containsKey(Constants.NAME_OF_ALL_PROPERTIES)) {
return propertyContainer.get(Constants.NAME_OF_ALL_PROPERTIES).get(graphPropertyName);
} else {
return NullValue.NULL;
return Values.NULL;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.neo4j.driver.Value;

/**
* A wrapper or marker for a Neo4j {@link org.neo4j.driver.internal.value.MapValue} that needs to be unwrapped when used
* A wrapper or marker for a Neo4j {@code org.neo4j.driver.internal.value.MapValue} that needs to be unwrapped when used
* for properties.
* This class exists solely for projection / filtering purposes: It allows the {@link DefaultNeo4jEntityConverter} to keep
* the composite properties together as long as possible (in the form of above's {@code MapValue}. Thus, the key in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.neo4j.repository.query;

import java.io.Serial;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Locale;
Expand All @@ -24,10 +25,8 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.apache.commons.logging.LogFactory;
import org.apiguardian.api.API;
import org.neo4j.cypherdsl.core.internal.SchemaNames;
import org.springframework.core.log.LogAccessor;
import org.neo4j.cypherdsl.support.schema_name.SchemaNames;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.neo4j.core.mapping.CypherGenerator;
Expand Down Expand Up @@ -57,8 +56,6 @@ public final class Neo4jSpelSupport {
public static String FUNCTION_ALL_OF = "allOf";
public static String FUNCTION_ORDER_BY = "orderBy";

private static final LogAccessor LOG = new LogAccessor(LogFactory.getLog(Neo4jSpelSupport.class));

/**
* Takes {@code arg} and tries to either extract a {@link Sort sort} from it or cast it to a sort. That sort is
* than past to the {@link CypherGenerator} that renders a valid order by fragment which replaces the SpEL placeholder
Expand Down Expand Up @@ -90,9 +87,8 @@ public static LiteralReplacement orderBy(@Nullable Object arg) {
*/
public static LiteralReplacement literal(@Nullable Object arg) {

LiteralReplacement literalReplacement = StringBasedLiteralReplacement
return StringBasedLiteralReplacement
.withTargetAndValue(LiteralReplacement.Target.UNSPECIFIED, arg == null ? "" : arg.toString());
return literalReplacement;
}

public static LiteralReplacement anyOf(@Nullable Object arg) {
Expand All @@ -113,7 +109,7 @@ private static LiteralReplacement labels(@Nullable Object arg, String joinOn) {
private static String joinStrings(Object arg, String joinOn) {
if (arg instanceof Collection) {
return ((Collection<?>) arg).stream()
.map(o -> SchemaNames.sanitize(o.toString()).get())
.map(o -> SchemaNames.sanitize(o.toString()).orElseThrow())
.collect(Collectors.joining(joinOn));
}

Expand All @@ -130,7 +126,7 @@ private static String joinStrings(Object arg, String joinOn) {
* comes in handy in places where non-parameterizable things should be created dynamic, for example matching on
* set of dynamic labels, types order ordering in a dynamic way.
*/
interface LiteralReplacement {
public interface LiteralReplacement {

/**
* The target of this replacement. While a replacement can be used theoretically everywhere in the query, the target
Expand All @@ -155,7 +151,10 @@ private static class StringBasedLiteralReplacement implements LiteralReplacement
* the creation of too many small objects.
*/
private static final Map<String, LiteralReplacement> INSTANCES =
new LinkedHashMap<String, LiteralReplacement>(DEFAULT_CACHE_SIZE) {
new LinkedHashMap<>(DEFAULT_CACHE_SIZE) {
@Serial
private static final long serialVersionUID = 195460174410223375L;

@Override
protected boolean removeEldestEntry(Map.Entry<String, LiteralReplacement> eldest) {
return size() > DEFAULT_CACHE_SIZE;
Expand All @@ -167,7 +166,7 @@ protected boolean removeEldestEntry(Map.Entry<String, LiteralReplacement> eldest
static LiteralReplacement withTargetAndValue(LiteralReplacement.Target target, @Nullable String value) {

String valueUsed = value == null ? "" : value;
String key = new StringBuilder(target.name()).append("_").append(valueUsed).toString();
String key = target.name() + "_" + valueUsed;

long stamp = LOCK.tryOptimisticRead();
if (LOCK.validate(stamp) && INSTANCES.containsKey(key)) {
Expand Down