, U> Path dot(A attribute) {
* @return
*/
public , U> Path dot(P attribute) {
- return new Path(add(attribute));
+ return new Path<>(add(attribute));
}
private List> add(Attribute, ?> attribute) {
Assert.notNull(attribute, "Attribute must not be null");
- List> newAttributes = new ArrayList>(attributes.size() + 1);
+ List> newAttributes = new ArrayList<>(attributes.size() + 1);
newAttributes.addAll(attributes);
newAttributes.add(attribute);
return newAttributes;
@@ -331,7 +326,7 @@ public static class JpaOrder extends Order {
* {@link Sort#DEFAULT_DIRECTION}
*
* @param direction can be {@literal null}, will default to {@link Sort#DEFAULT_DIRECTION}.
- * @param property must not be {@literal null}.
+ * @param property must not be {@literal null}.
*/
private JpaOrder(@Nullable Direction direction, String property) {
this(direction, property, NullHandling.NATIVE);
@@ -341,8 +336,8 @@ private JpaOrder(@Nullable Direction direction, String property) {
* Creates a new {@link Order} instance. if order is {@literal null} then order defaults to
* {@link Sort#DEFAULT_DIRECTION}.
*
- * @param direction can be {@literal null}, will default to {@link Sort#DEFAULT_DIRECTION}.
- * @param property must not be {@literal null}.
+ * @param direction can be {@literal null}, will default to {@link Sort#DEFAULT_DIRECTION}.
+ * @param property must not be {@literal null}.
* @param nullHandlingHint can be {@literal null}, will default to {@link NullHandling#NATIVE}.
*/
private JpaOrder(@Nullable Direction direction, String property, NullHandling nullHandlingHint) {
@@ -350,7 +345,7 @@ private JpaOrder(@Nullable Direction direction, String property, NullHandling nu
}
private JpaOrder(@Nullable Direction direction, String property, boolean ignoreCase, NullHandling nullHandling,
- boolean unsafe) {
+ boolean unsafe) {
super(direction, property, ignoreCase, nullHandling);
this.unsafe = unsafe;
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/Specification.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/Specification.java
index a5b39ef017..d28031b76d 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/Specification.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/Specification.java
@@ -15,18 +15,17 @@
*/
package org.springframework.data.jpa.domain;
-import jakarta.persistence.criteria.CriteriaBuilder;
-import jakarta.persistence.criteria.CriteriaDelete;
-import jakarta.persistence.criteria.CriteriaQuery;
-import jakarta.persistence.criteria.Predicate;
-import jakarta.persistence.criteria.Root;
-
import java.io.Serializable;
import java.util.Arrays;
import java.util.stream.StreamSupport;
import org.springframework.lang.Nullable;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.Predicate;
+import jakarta.persistence.criteria.Root;
+
/**
* Specification in the sense of Domain Driven Design.
*
@@ -37,6 +36,7 @@
* @author Mark Paluch
* @author Jens Schauder
* @author Daniel Shuy
+ * @author Christian Wörz
*/
public interface Specification extends Serializable {
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java
index 6f0773974f..15cfc705dc 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java
@@ -15,13 +15,9 @@
*/
package org.springframework.data.jpa.mapping;
-import jakarta.persistence.*;
-import jakarta.persistence.metamodel.Metamodel;
-
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Set;
import org.springframework.core.annotation.AnnotationUtils;
@@ -37,6 +33,9 @@
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
+import jakarta.persistence.*;
+import jakarta.persistence.metamodel.Metamodel;
+
/**
* {@link JpaPersistentProperty} implementation using a JPA {@link Metamodel}.
*
@@ -46,38 +45,17 @@
* @author Christoph Strobl
* @author Mark Paluch
* @author Erik Pellizzon
+ * @author Christian Wörz
* @since 1.3
*/
class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty
implements JpaPersistentProperty {
- private static final Collection> ASSOCIATION_ANNOTATIONS;
- private static final Collection> ID_ANNOTATIONS;
- private static final Collection> UPDATEABLE_ANNOTATIONS;
-
- static {
-
- Set> annotations = new HashSet<>();
- annotations.add(OneToMany.class);
- annotations.add(OneToOne.class);
- annotations.add(ManyToMany.class);
- annotations.add(ManyToOne.class);
-
- ASSOCIATION_ANNOTATIONS = Collections.unmodifiableSet(annotations);
-
- annotations = new HashSet<>();
- annotations.add(Id.class);
- annotations.add(EmbeddedId.class);
-
- ID_ANNOTATIONS = Collections.unmodifiableSet(annotations);
-
- annotations = new HashSet<>();
- annotations.add(Column.class);
- annotations.add(OrderColumn.class);
-
- UPDATEABLE_ANNOTATIONS = Collections.unmodifiableSet(annotations);
- }
-
+ private static final Collection> ASSOCIATION_ANNOTATIONS = Set.of(OneToMany.class,
+ OneToOne.class, ManyToMany.class, ManyToOne.class);
+ private static final Collection> ID_ANNOTATIONS = Set.of(Id.class, EmbeddedId.class);
+ private static final Collection> UPDATEABLE_ANNOTATIONS = Set.of(Column.class,
+ OrderColumn.class);
private final @Nullable Boolean usePropertyAccess;
private final @Nullable TypeInformation> associationTargetType;
private final boolean updateable;
@@ -107,7 +85,7 @@ public JpaPersistentPropertyImpl(JpaMetamodel metamodel, Property property,
this.associationTargetType = detectAssociationTargetType();
this.updateable = detectUpdatability();
- this.isIdProperty = Lazy.of(() -> ID_ANNOTATIONS.stream().anyMatch(it -> isAnnotationPresent(it)) //
+ this.isIdProperty = Lazy.of(() -> ID_ANNOTATIONS.stream().anyMatch(this::isAnnotationPresent) //
|| metamodel.isSingleIdAttribute(getOwner().getType(), getName(), getType()));
this.isEntity = Lazy.of(() -> metamodel.isMappedType(getActualType()));
}
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/EntityGraph.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/EntityGraph.java
index 79de53344b..f96ef8fe2e 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/EntityGraph.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/EntityGraph.java
@@ -24,16 +24,15 @@
import org.springframework.data.jpa.repository.query.JpaQueryMethod;
/**
- * Annotation to configure the JPA 2.1 {@link jakarta.persistence.EntityGraph}s that should be used on repository methods.
- * Since 1.9 we support the definition of dynamic {@link EntityGraph}s by allowing to customize the fetch-graph via
- * {@link #attributePaths()} ad-hoc fetch-graph configuration.
- *
- * If {@link #attributePaths()} are specified then we ignore the entity-graph name {@link #value()} and treat this
- * {@link EntityGraph} as dynamic.
+ * Annotation to configure the JPA 2.1 {@link jakarta.persistence.EntityGraph}s that should be used on repository
+ * methods. Since 1.9 we support the definition of dynamic {@link EntityGraph}s by allowing to customize the fetch-graph
+ * via {@link #attributePaths()} ad-hoc fetch-graph configuration. If {@link #attributePaths()} are specified then we
+ * ignore the entity-graph name {@link #value()} and treat this {@link EntityGraph} as dynamic.
*
* @author Christoph Strobl
* @author Thomas Darimont
* @author Oerd Cukalla
+ * @author Christian Wörz
* @since 1.6
*/
@Retention(RetentionPolicy.RUNTIME)
@@ -71,7 +70,7 @@
* @author Thomas Darimont
* @since 1.6
*/
- public enum EntityGraphType {
+ enum EntityGraphType {
/**
* When the jakarta.persistence.loadgraph property is used to specify an entity graph, attributes that are specified
@@ -84,9 +83,9 @@ public enum EntityGraphType {
LOAD("jakarta.persistence.loadgraph"),
/**
- * When the jakarta.persistence.fetchgraph property is used to specify an entity graph, attributes that are specified
- * by attribute nodes of the entity graph are treated as FetchType.EAGER and attributes that are not specified are
- * treated as FetchType.LAZY
+ * When the jakarta.persistence.fetchgraph property is used to specify an entity graph, attributes that are
+ * specified by attribute nodes of the entity graph are treated as FetchType.EAGER and attributes that are not
+ * specified are treated as FetchType.LAZY
*
* @see JPA 2.1
* Specification: 3.7.4.1 Fetch Graph Semantics
@@ -95,7 +94,7 @@ public enum EntityGraphType {
private final String key;
- private EntityGraphType(String value) {
+ EntityGraphType(String value) {
this.key = value;
}
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot/JpaRuntimeHints.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot/JpaRuntimeHints.java
index d097bfcae8..4a44905282 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot/JpaRuntimeHints.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot/JpaRuntimeHints.java
@@ -15,8 +15,6 @@
*/
package org.springframework.data.jpa.repository.aot;
-import jakarta.persistence.NamedEntityGraph;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -39,10 +37,13 @@
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
+import jakarta.persistence.NamedEntityGraph;
+
/**
* Runtime hints for JPA AOT processing.
*
* @author Christoph Strobl
+ * @author Christian Wörz
* @since 3.0
*/
class JpaRuntimeHints implements RuntimeHintsRegistrar {
@@ -88,9 +89,8 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
// streaming results requires reflective access to jakarta.persistence.Query#getResultAsStream
hints.reflection().registerType(jakarta.persistence.Query.class, MemberCategory.INTROSPECT_PUBLIC_METHODS);
- hints.reflection().registerType(jakarta.persistence.Query.class, hint -> {
- hint.withMethod("getResultStream", Collections.emptyList(), ExecutableMode.INVOKE);
- });
+ hints.reflection().registerType(jakarta.persistence.Query.class,
+ hint -> hint.withMethod("getResultStream", Collections.emptyList(), ExecutableMode.INVOKE));
hints.reflection().registerType(NamedEntityGraph.class,
hint -> hint.onReachableType(EntityGraph.class).withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EscapeCharacter.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EscapeCharacter.java
index a6d1e18d9b..f46c56378e 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EscapeCharacter.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EscapeCharacter.java
@@ -27,6 +27,7 @@
*
* @author Jens Schauder
* @author Oliver Drotbohm
+ * @author Christian Wörz
*/
public final class EscapeCharacter {
@@ -69,11 +70,10 @@ public boolean equals(Object o) {
return true;
}
- if (!(o instanceof EscapeCharacter)) {
+ if (!(o instanceof EscapeCharacter that)) {
return false;
}
- EscapeCharacter that = (EscapeCharacter) o;
return escapeCharacter == that.escapeCharacter;
}
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java
index e705664a7f..a9f15ac790 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java
@@ -24,6 +24,7 @@
* An ANTLR {@link org.antlr.v4.runtime.tree.ParseTreeVisitor} that renders an HQL query without making any changes.
*
* @author Greg Turnquist
+ * @author Christian Wörz
* @since 3.1
*/
class HqlQueryRenderer extends HqlBaseVisitor> {
@@ -341,9 +342,7 @@ public List visitEntityWithJoins(HqlParser.EntityWithJoins
tokens.addAll(visit(ctx.fromRoot()));
SPACE(tokens);
- ctx.joinSpecifier().forEach(joinSpecifierContext -> {
- tokens.addAll(visit(joinSpecifierContext));
- });
+ ctx.joinSpecifier().forEach(joinSpecifierContext -> tokens.addAll(visit(joinSpecifierContext)));
return tokens;
}
@@ -1455,9 +1454,8 @@ public List visitSimpleCaseExpression(HqlParser.SimpleCase
tokens.add(new JpaQueryParsingToken(ctx.CASE()));
tokens.addAll(visit(ctx.expressionOrPredicate(0)));
- ctx.caseWhenExpressionClause().forEach(caseWhenExpressionClauseContext -> {
- tokens.addAll(visit(caseWhenExpressionClauseContext));
- });
+ ctx.caseWhenExpressionClause()
+ .forEach(caseWhenExpressionClauseContext -> tokens.addAll(visit(caseWhenExpressionClauseContext)));
if (ctx.ELSE() != null) {
@@ -1477,9 +1475,8 @@ public List visitSearchedCaseExpression(HqlParser.Searched
tokens.add(new JpaQueryParsingToken(ctx.CASE()));
- ctx.caseWhenPredicateClause().forEach(caseWhenPredicateClauseContext -> {
- tokens.addAll(visit(caseWhenPredicateClauseContext));
- });
+ ctx.caseWhenPredicateClause()
+ .forEach(caseWhenPredicateClauseContext -> tokens.addAll(visit(caseWhenPredicateClauseContext)));
if (ctx.ELSE() != null) {
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java
index 03a92fed5e..44057d0ba9 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java
@@ -18,6 +18,20 @@
import static org.springframework.data.jpa.repository.query.JSqlParserUtils.*;
import static org.springframework.data.jpa.repository.query.QueryUtils.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.springframework.data.domain.Sort;
+import org.springframework.lang.Nullable;
+import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.expression.Alias;
import net.sf.jsqlparser.expression.Expression;
@@ -39,26 +53,13 @@
import net.sf.jsqlparser.statement.update.Update;
import net.sf.jsqlparser.statement.values.ValuesStatement;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.springframework.data.domain.Sort;
-import org.springframework.lang.Nullable;
-import org.springframework.util.Assert;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
-
/**
* The implementation of {@link QueryEnhancer} using JSqlParser.
*
* @author Diego Krupitza
* @author Greg Turnquist
* @author Geoffrey Deremetz
+ * @author Christian Wörz
* @since 2.7.0
*/
public class JSqlParserQueryEnhancer implements QueryEnhancer {
@@ -120,7 +121,7 @@ public String applySorting(Sort sort, @Nullable String alias) {
Select selectStatement = parseSelectStatement(queryString);
- if (selectStatement.getSelectBody()instanceof SetOperationList setOperationList) {
+ if (selectStatement.getSelectBody() instanceof SetOperationList setOperationList) {
return applySortingToSetOperationList(setOperationList, sort);
} else if (!(selectStatement.getSelectBody() instanceof PlainSelect)) {
return queryString;
@@ -221,7 +222,7 @@ private Set getJoinAliases(String query) {
}
Select selectStatement = (Select) statement;
- if (selectStatement.getSelectBody()instanceof PlainSelect selectBody) {
+ if (selectStatement.getSelectBody() instanceof PlainSelect selectBody) {
return getJoinAliases(selectBody);
}
@@ -319,7 +320,7 @@ private String detectAlias(String query) {
* ValuesStatement has no alias
* SetOperation can have multiple alias for each operation item
*/
- if (!(selectStatement.getSelectBody()instanceof PlainSelect selectBody)) {
+ if (!(selectStatement.getSelectBody() instanceof PlainSelect selectBody)) {
return null;
}
@@ -374,7 +375,7 @@ public String createCountQueryFor(@Nullable String countProjection) {
/*
We only support count queries for {@link PlainSelect}.
*/
- if (!(selectStatement.getSelectBody()instanceof PlainSelect selectBody)) {
+ if (!(selectStatement.getSelectBody() instanceof PlainSelect selectBody)) {
return this.query.getQueryString();
}
@@ -441,7 +442,7 @@ public String getProjection() {
SelectBody selectBody = selectStatement.getSelectBody();
- if (selectStatement.getSelectBody()instanceof SetOperationList setOperationList) {
+ if (selectStatement.getSelectBody() instanceof SetOperationList setOperationList) {
// using the first one since for setoperations the projection has to be the same
selectBody = setOperationList.getSelects().get(0);
@@ -517,7 +518,7 @@ public DeclaredQuery getQuery() {
*
*/
enum ParsedType {
- DELETE, UPDATE, SELECT, INSERT, MERGE, OTHER;
+ DELETE, UPDATE, SELECT, INSERT, MERGE, OTHER
}
}
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaCountQueryCreator.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaCountQueryCreator.java
index 0d4bda7faa..e6a635b044 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaCountQueryCreator.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaCountQueryCreator.java
@@ -15,17 +15,17 @@
*/
package org.springframework.data.jpa.repository.query;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.repository.query.ReturnedType;
+import org.springframework.data.repository.query.parser.PartTree;
+import org.springframework.lang.Nullable;
+
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Expression;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.repository.query.ReturnedType;
-import org.springframework.data.repository.query.parser.PartTree;
-import org.springframework.lang.Nullable;
-
/**
* Special {@link JpaQueryCreator} that creates a count projecting query.
*
@@ -33,6 +33,7 @@
* @author Marc Lefrançois
* @author Mark Paluch
* @author Greg Turnquist
+ * @author Christian Wörz
*/
public class JpaCountQueryCreator extends JpaQueryCreator {
@@ -55,17 +56,17 @@ public JpaCountQueryCreator(PartTree tree, ReturnedType type, CriteriaBuilder bu
}
@Override
- protected CriteriaQuery extends Object> createCriteriaQuery(CriteriaBuilder builder, ReturnedType type) {
+ protected CriteriaQuery> createCriteriaQuery(CriteriaBuilder builder, ReturnedType type) {
return builder.createQuery(Long.class);
}
@Override
@SuppressWarnings("unchecked")
- protected CriteriaQuery extends Object> complete(@Nullable Predicate predicate, Sort sort,
- CriteriaQuery extends Object> query, CriteriaBuilder builder, Root> root) {
+ protected CriteriaQuery> complete(@Nullable Predicate predicate, Sort sort, CriteriaQuery> query,
+ CriteriaBuilder builder, Root> root) {
- CriteriaQuery extends Object> select = query.select(getCountQuery(query, builder, root));
+ CriteriaQuery> select = query.select(getCountQuery(query, builder, root));
return predicate == null ? select : select.where(predicate);
}
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java
index 431d1b7111..b3852e3f6d 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java
@@ -18,16 +18,6 @@
import static org.springframework.data.jpa.repository.query.QueryUtils.*;
import static org.springframework.data.repository.query.parser.Part.Type.*;
-import jakarta.persistence.criteria.CriteriaBuilder;
-import jakarta.persistence.criteria.CriteriaQuery;
-import jakarta.persistence.criteria.Expression;
-import jakarta.persistence.criteria.ParameterExpression;
-import jakarta.persistence.criteria.Path;
-import jakarta.persistence.criteria.Predicate;
-import jakarta.persistence.criteria.Root;
-import jakarta.persistence.criteria.Selection;
-import jakarta.persistence.metamodel.SingularAttribute;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -45,6 +35,16 @@
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.Expression;
+import jakarta.persistence.criteria.ParameterExpression;
+import jakarta.persistence.criteria.Path;
+import jakarta.persistence.criteria.Predicate;
+import jakarta.persistence.criteria.Root;
+import jakarta.persistence.criteria.Selection;
+import jakarta.persistence.metamodel.SingularAttribute;
+
/**
* Query creator to create a {@link CriteriaQuery} from a {@link PartTree}.
*
@@ -56,12 +56,13 @@
* @author Moritz Becker
* @author Andrey Kovalev
* @author Greg Turnquist
+ * @author Christian Wörz
*/
-public class JpaQueryCreator extends AbstractQueryCreator, Predicate> {
+public class JpaQueryCreator extends AbstractQueryCreator, Predicate> {
private final CriteriaBuilder builder;
private final Root> root;
- private final CriteriaQuery extends Object> query;
+ private final CriteriaQuery> query;
private final ParameterMetadataProvider provider;
private final ReturnedType returnedType;
private final PartTree tree;
@@ -98,7 +99,7 @@ public JpaQueryCreator(PartTree tree, ReturnedType type, CriteriaBuilder builder
* @param type will never be {@literal null}.
* @return must not be {@literal null}.
*/
- protected CriteriaQuery extends Object> createCriteriaQuery(CriteriaBuilder builder, ReturnedType type) {
+ protected CriteriaQuery> createCriteriaQuery(CriteriaBuilder builder, ReturnedType type) {
Class> typeToRead = tree.isDelete() ? type.getDomainType() : type.getTypeToRead();
@@ -137,7 +138,7 @@ protected Predicate or(Predicate base, Predicate predicate) {
* {@link CriteriaQuery} and {@link CriteriaBuilder}.
*/
@Override
- protected final CriteriaQuery extends Object> complete(Predicate predicate, Sort sort) {
+ protected final CriteriaQuery> complete(Predicate predicate, Sort sort) {
return complete(predicate, sort, query, builder, root);
}
@@ -152,8 +153,8 @@ protected final CriteriaQuery extends Object> complete(Predicate predicate, So
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
- protected CriteriaQuery extends Object> complete(@Nullable Predicate predicate, Sort sort,
- CriteriaQuery extends Object> query, CriteriaBuilder builder, Root> root) {
+ protected CriteriaQuery> complete(@Nullable Predicate predicate, Sort sort, CriteriaQuery> query,
+ CriteriaBuilder builder, Root> root) {
if (returnedType.needsCustomConstruction()) {
@@ -191,7 +192,7 @@ protected CriteriaQuery extends Object> complete(@Nullable Predicate predicate
query = query.select((Root) root);
}
- CriteriaQuery extends Object> select = query.orderBy(QueryUtils.toOrders(sort, root, builder));
+ CriteriaQuery> select = query.orderBy(QueryUtils.toOrders(sort, root, builder));
return predicate == null ? select : select.where(predicate);
}
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java
index 8083f49979..97981cb60f 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java
@@ -15,8 +15,6 @@
*/
package org.springframework.data.jpa.repository.query;
-import jakarta.persistence.EntityManager;
-
import java.lang.reflect.Method;
import org.apache.commons.logging.Log;
@@ -35,6 +33,8 @@
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
+import jakarta.persistence.EntityManager;
+
/**
* Query lookup strategy to execute finders.
*
@@ -43,6 +43,7 @@
* @author Mark Paluch
* @author Réda Housni Alaoui
* @author Greg Turnquist
+ * @author Christian Wörz
*/
public final class JpaQueryLookupStrategy {
@@ -275,20 +276,16 @@ public static QueryLookupStrategy create(EntityManager em, JpaQueryMethodFactory
Assert.notNull(em, "EntityManager must not be null");
Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null");
- switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
- case CREATE:
- return new CreateQueryLookupStrategy(em, queryMethodFactory, queryRewriterProvider, escape);
- case USE_DECLARED_QUERY:
- return new DeclaredQueryLookupStrategy(em, queryMethodFactory, evaluationContextProvider,
- queryRewriterProvider);
- case CREATE_IF_NOT_FOUND:
- return new CreateIfNotFoundQueryLookupStrategy(em, queryMethodFactory,
- new CreateQueryLookupStrategy(em, queryMethodFactory, queryRewriterProvider, escape),
- new DeclaredQueryLookupStrategy(em, queryMethodFactory, evaluationContextProvider, queryRewriterProvider),
- queryRewriterProvider);
- default:
- throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s", key));
- }
+ return switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
+ case CREATE -> new CreateQueryLookupStrategy(em, queryMethodFactory, queryRewriterProvider, escape);
+ case USE_DECLARED_QUERY ->
+ new DeclaredQueryLookupStrategy(em, queryMethodFactory, evaluationContextProvider, queryRewriterProvider);
+ case CREATE_IF_NOT_FOUND -> new CreateIfNotFoundQueryLookupStrategy(em, queryMethodFactory,
+ new CreateQueryLookupStrategy(em, queryMethodFactory, queryRewriterProvider, escape),
+ new DeclaredQueryLookupStrategy(em, queryMethodFactory, evaluationContextProvider, queryRewriterProvider),
+ queryRewriterProvider);
+ default -> throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s", key));
+ };
}
/**
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryMethod.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryMethod.java
index ed566ba52c..2e22df8f58 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryMethod.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryMethod.java
@@ -15,14 +15,10 @@
*/
package org.springframework.data.jpa.repository.query;
-import jakarta.persistence.LockModeType;
-import jakarta.persistence.QueryHint;
-
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -51,6 +47,9 @@
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.util.StringUtils;
+import jakarta.persistence.LockModeType;
+import jakarta.persistence.QueryHint;
+
/**
* JPA specific extension of {@link QueryMethod}.
*
@@ -62,6 +61,7 @@
* @author Сергей Цыпанов
* @author Réda Housni Alaoui
* @author Greg Turnquist
+ * @author Christian Wörz
*/
public class JpaQueryMethod extends QueryMethod {
@@ -70,20 +70,10 @@ public class JpaQueryMethod extends QueryMethod {
* "https://download.oracle.com/otn-pub/jcp/persistence-2.0-fr-eval-oth-JSpec/persistence-2_0-final-spec.pdf">JPA
* 2.0 Specification 2.2 Persistent Fields and Properties Page 23 - Top paragraph.
*/
- private static final Set