Skip to content

Commit 265209a

Browse files
committed
Remove OpenJPA leftovers.
Remove unused tests, simplify findAllById(Iterable) implementation. Closes #3741
1 parent 7804874 commit 265209a

22 files changed

+14
-596
lines changed

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@
195195
</includes>
196196
<excludes>
197197
<exclude>**/*UnitTests.java</exclude>
198-
<exclude>**/OpenJpa*</exclude>
199198
<exclude>**/EclipseLink*</exclude>
200199
<exclude>**/MySql*</exclude>
201200
<exclude>**/Postgres*</exclude>

spring-data-jpa/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@
289289
</includes>
290290
<excludes>
291291
<exclude>**/*UnitTests.java</exclude>
292-
<exclude>**/OpenJpa*</exclude>
293292
<exclude>**/EclipseLink*</exclude>
294293
<exclude>**/MySql*</exclude>
295294
<exclude>**/Postgres*</exclude>

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

Lines changed: 11 additions & 47 deletions
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;
@@ -260,7 +257,7 @@ public void deleteAllByIdInBatch(Iterable<ID> ids) {
260257
/*
261258
* Some JPA providers require {@code ids} to be a {@link Collection} so we must convert if it's not already.
262259
*/
263-
Collection<ID> idCollection = toCollection(ids);
260+
Collection<ID> idCollection = toCollection(ids);
264261
query.setParameter("ids", idCollection);
265262

266263
applyQueryHints(query);
@@ -424,10 +421,14 @@ public List<T> findAllById(Iterable<ID> ids) {
424421

425422
Collection<ID> idCollection = toCollection(ids);
426423

427-
ByIdsSpecification<T> specification = new ByIdsSpecification<>(entityInformation);
428-
TypedQuery<T> query = getQuery(specification, Sort.unsorted());
424+
TypedQuery<T> query = getQuery((root, q, criteriaBuilder) -> {
429425

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

433434
@Override
@@ -1062,37 +1063,6 @@ private static long executeCountQuery(TypedQuery<Long> query) {
10621063
return total;
10631064
}
10641065

1065-
/**
1066-
* Specification that gives access to the {@link Parameter} instance used to bind the ids for
1067-
* {@link SimpleJpaRepository#findAllById(Iterable)}. Workaround for OpenJPA not binding collections to in-clauses
1068-
* correctly when using by-name binding.
1069-
*
1070-
* @author Oliver Gierke
1071-
* @see <a href="https://issues.apache.org/jira/browse/OPENJPA-2018?focusedCommentId=13924055">OPENJPA-2018</a>
1072-
*/
1073-
@SuppressWarnings("rawtypes")
1074-
private static final class ByIdsSpecification<T> implements Specification<T> {
1075-
1076-
private static final @Serial long serialVersionUID = 1L;
1077-
1078-
private final JpaEntityInformation<T, ?> entityInformation;
1079-
1080-
@Nullable ParameterExpression<Collection<?>> parameter;
1081-
1082-
ByIdsSpecification(JpaEntityInformation<T, ?> entityInformation) {
1083-
this.entityInformation = entityInformation;
1084-
}
1085-
1086-
@Override
1087-
@SuppressWarnings("unchecked")
1088-
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
1089-
1090-
Path<?> path = root.get(entityInformation.getIdAttribute());
1091-
parameter = (ParameterExpression<Collection<?>>) (ParameterExpression) cb.parameter(Collection.class);
1092-
return path.in(parameter);
1093-
}
1094-
}
1095-
10961066
/**
10971067
* {@link Specification} that gives access to the {@link Predicate} instance representing the values contained in the
10981068
* {@link Example}.
@@ -1101,26 +1071,20 @@ public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuild
11011071
* @author Christoph Strobl
11021072
* @since 1.10
11031073
*/
1104-
private static class ExampleSpecification<T> implements Specification<T> {
1105-
1106-
private static final @Serial long serialVersionUID = 1L;
1107-
1108-
private final Example<T> example;
1109-
private final EscapeCharacter escapeCharacter;
1074+
private record ExampleSpecification<T>(Example<T> example,
1075+
EscapeCharacter escapeCharacter) implements Specification<T> {
11101076

11111077
/**
11121078
* Creates new {@link ExampleSpecification}.
11131079
*
11141080
* @param example the example to base the specification of. Must not be {@literal null}.
11151081
* @param escapeCharacter the escape character to use for like expressions. Must not be {@literal null}.
11161082
*/
1117-
ExampleSpecification(Example<T> example, EscapeCharacter escapeCharacter) {
1083+
private ExampleSpecification {
11181084

11191085
Assert.notNull(example, EXAMPLE_MUST_NOT_BE_NULL);
11201086
Assert.notNull(escapeCharacter, "EscapeCharacter must not be null");
11211087

1122-
this.example = example;
1123-
this.escapeCharacter = escapeCharacter;
11241088
}
11251089

11261090
@Override

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 42 deletions
This file was deleted.

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 0 additions & 87 deletions
This file was deleted.

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

Lines changed: 0 additions & 27 deletions
This file was deleted.

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

Lines changed: 0 additions & 33 deletions
This file was deleted.

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

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)