Skip to content

Commit 23d2e9a

Browse files
committed
Remove OpenJPA leftovers.
Remove unused tests, simplify findAllById(Iterable) implementation. Closes #3741
1 parent b4713d0 commit 23d2e9a

21 files changed

+14
-595
lines changed

spring-data-jpa/pom.xml

-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@
290290
</includes>
291291
<excludes>
292292
<exclude>**/*UnitTests.java</exclude>
293-
<exclude>**/OpenJpa*</exclude>
294293
<exclude>**/EclipseLink*</exclude>
295294
<exclude>**/MySql*</exclude>
296295
<exclude>**/Postgres*</exclude>

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java

+11-47
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,17 @@
1919

2020
import jakarta.persistence.EntityManager;
2121
import jakarta.persistence.LockModeType;
22-
import jakarta.persistence.Parameter;
2322
import jakarta.persistence.Query;
2423
import jakarta.persistence.TypedQuery;
2524
import jakarta.persistence.criteria.CriteriaBuilder;
2625
import jakarta.persistence.criteria.CriteriaDelete;
2726
import jakarta.persistence.criteria.CriteriaQuery;
2827
import jakarta.persistence.criteria.CriteriaUpdate;
29-
import jakarta.persistence.criteria.ParameterExpression;
3028
import jakarta.persistence.criteria.Path;
3129
import jakarta.persistence.criteria.Predicate;
3230
import jakarta.persistence.criteria.Root;
3331
import jakarta.persistence.criteria.Selection;
3432

35-
import java.io.Serial;
3633
import java.util.ArrayList;
3734
import java.util.Collection;
3835
import java.util.Collections;
@@ -262,7 +259,7 @@ public void deleteAllByIdInBatch(Iterable<ID> ids) {
262259
/*
263260
* Some JPA providers require {@code ids} to be a {@link Collection} so we must convert if it's not already.
264261
*/
265-
Collection<ID> idCollection = toCollection(ids);
262+
Collection<ID> idCollection = toCollection(ids);
266263
query.setParameter("ids", idCollection);
267264

268265
applyQueryHints(query);
@@ -426,10 +423,14 @@ public List<T> findAllById(Iterable<ID> ids) {
426423

427424
Collection<ID> idCollection = toCollection(ids);
428425

429-
ByIdsSpecification<T> specification = new ByIdsSpecification<>(entityInformation);
430-
TypedQuery<T> query = getQuery(specification, Sort.unsorted());
426+
TypedQuery<T> query = getQuery((root, q, criteriaBuilder) -> {
431427

432-
return query.setParameter(specification.parameter, idCollection).getResultList();
428+
Path<?> path = root.get(entityInformation.getIdAttribute());
429+
return path.in(idCollection);
430+
431+
}, Sort.unsorted());
432+
433+
return query.getResultList();
433434
}
434435

435436
@Override
@@ -1083,37 +1084,6 @@ private static long executeCountQuery(TypedQuery<Long> query) {
10831084
return total;
10841085
}
10851086

1086-
/**
1087-
* Specification that gives access to the {@link Parameter} instance used to bind the ids for
1088-
* {@link SimpleJpaRepository#findAllById(Iterable)}. Workaround for OpenJPA not binding collections to in-clauses
1089-
* correctly when using by-name binding.
1090-
*
1091-
* @author Oliver Gierke
1092-
* @see <a href="https://issues.apache.org/jira/browse/OPENJPA-2018?focusedCommentId=13924055">OPENJPA-2018</a>
1093-
*/
1094-
@SuppressWarnings("rawtypes")
1095-
private static final class ByIdsSpecification<T> implements Specification<T> {
1096-
1097-
private static final @Serial long serialVersionUID = 1L;
1098-
1099-
private final JpaEntityInformation<T, ?> entityInformation;
1100-
1101-
@Nullable ParameterExpression<Collection<?>> parameter;
1102-
1103-
ByIdsSpecification(JpaEntityInformation<T, ?> entityInformation) {
1104-
this.entityInformation = entityInformation;
1105-
}
1106-
1107-
@Override
1108-
@SuppressWarnings("unchecked")
1109-
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
1110-
1111-
Path<?> path = root.get(entityInformation.getIdAttribute());
1112-
parameter = (ParameterExpression<Collection<?>>) (ParameterExpression) cb.parameter(Collection.class);
1113-
return path.in(parameter);
1114-
}
1115-
}
1116-
11171087
/**
11181088
* {@link Specification} that gives access to the {@link Predicate} instance representing the values contained in the
11191089
* {@link Example}.
@@ -1122,26 +1092,20 @@ public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuild
11221092
* @author Christoph Strobl
11231093
* @since 1.10
11241094
*/
1125-
private static class ExampleSpecification<T> implements Specification<T> {
1126-
1127-
private static final @Serial long serialVersionUID = 1L;
1128-
1129-
private final Example<T> example;
1130-
private final EscapeCharacter escapeCharacter;
1095+
private record ExampleSpecification<T>(Example<T> example,
1096+
EscapeCharacter escapeCharacter) implements Specification<T> {
11311097

11321098
/**
11331099
* Creates new {@link ExampleSpecification}.
11341100
*
11351101
* @param example the example to base the specification of. Must not be {@literal null}.
11361102
* @param escapeCharacter the escape character to use for like expressions. Must not be {@literal null}.
11371103
*/
1138-
ExampleSpecification(Example<T> example, EscapeCharacter escapeCharacter) {
1104+
private ExampleSpecification {
11391105

11401106
Assert.notNull(example, EXAMPLE_MUST_NOT_BE_NULL);
11411107
Assert.notNull(escapeCharacter, "EscapeCharacter must not be null");
11421108

1143-
this.example = example;
1144-
this.escapeCharacter = escapeCharacter;
11451109
}
11461110

11471111
@Override

spring-data-jpa/src/test/java/org/springframework/data/jpa/infrastructure/EclipseLinkMetamodelIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.springframework.test.context.ContextConfiguration;
2121

2222
/**
23-
* Metamodel tests using OpenJPA.
23+
* Metamodel tests using Eclipselink.
2424
*
2525
* @author Oliver Gierke
2626
*/

spring-data-jpa/src/test/java/org/springframework/data/jpa/infrastructure/OpenJpaMetamodelIntegrationTests.java

-42
This file was deleted.

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/OpenJpaEntityGraphRepositoryMethodsIntegrationTests.java

-24
This file was deleted.

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/OpenJpaNamespaceUserRepositoryTests.java

-87
This file was deleted.

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/OpenJpaParentRepositoryIntegrationTests.java

-27
This file was deleted.

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/OpenJpaRepositoryWithCompositeKeyIntegrationTests.java

-33
This file was deleted.

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/OpenJpaStoredProcedureIntegrationTests.java

-35
This file was deleted.

0 commit comments

Comments
 (0)