Skip to content

Commit 582bb18

Browse files
committed
Migrate to Jakarta EE 9.
Closes #2305
1 parent e800df9 commit 582bb18

File tree

230 files changed

+821
-786
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+821
-786
lines changed

pom.xml

+48-14
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<dist.key>DATAJPA</dist.key>
2525

26-
<eclipselink>2.7.9</eclipselink>
26+
<eclipselink>3.0.2</eclipselink>
2727
<hibernate>5.6.0.Final</hibernate>
2828
<mysql-connector-java>8.0.23</mysql-connector-java>
2929
<postgresql>42.2.19</postgresql>
@@ -293,30 +293,37 @@
293293

294294
<dependency>
295295
<groupId>${hibernate.groupId}</groupId>
296-
<artifactId>hibernate-core</artifactId>
296+
<artifactId>hibernate-core-jakarta</artifactId>
297297
<version>${hibernate}</version>
298298
<optional>true</optional>
299299
</dependency>
300300

301301
<dependency>
302302
<groupId>${hibernate.groupId}</groupId>
303-
<artifactId>hibernate-jpamodelgen</artifactId>
303+
<artifactId>hibernate-jpamodelgen-jakarta</artifactId>
304304
<version>${hibernate}</version>
305305
<scope>provided</scope>
306306
</dependency>
307307

308+
<dependency>
309+
<groupId>jakarta.annotation</groupId>
310+
<artifactId>jakarta.annotation-api</artifactId>
311+
<version>${jakarta-annotation-api}</version>
312+
</dependency>
313+
308314
<!-- QueryDsl -->
309315
<dependency>
310316
<groupId>com.querydsl</groupId>
311317
<artifactId>querydsl-apt</artifactId>
312318
<version>${querydsl}</version>
313-
<classifier>jpa</classifier>
319+
<classifier>jakarta</classifier>
314320
<scope>provided</scope>
315321
</dependency>
316322

317323
<dependency>
318324
<groupId>com.querydsl</groupId>
319325
<artifactId>querydsl-jpa</artifactId>
326+
<classifier>jakarta</classifier>
320327
<version>${querydsl}</version>
321328
<optional>true</optional>
322329
</dependency>
@@ -339,31 +346,58 @@
339346
</dependency>
340347

341348
<dependency>
342-
<groupId>javax.interceptor</groupId>
343-
<artifactId>javax.interceptor-api</artifactId>
344-
<version>1.2.1</version>
349+
<groupId>jakarta.interceptor</groupId>
350+
<artifactId>jakarta.interceptor-api</artifactId>
351+
<version>2.0.0</version>
345352
<scope>test</scope>
346353
</dependency>
347354

348355
<dependency>
349-
<groupId>javax.enterprise</groupId>
350-
<artifactId>cdi-api</artifactId>
356+
<groupId>jakarta.enterprise</groupId>
357+
<artifactId>jakarta.enterprise.cdi-api</artifactId>
351358
<version>${cdi}</version>
352359
<scope>provided</scope>
353360
<optional>true</optional>
354361
</dependency>
355362

363+
<!--
364+
Apache Open Web beans offers a jakarta based version using maven classifiers.
365+
Unfortunately the dependencies are broken, so one has to exclude the broken ones and add the proper ones
366+
explicitly.
367+
368+
This can be simpliefied once https://issues.apache.org/jira/browse/OWB-1368 is fixed.
369+
370+
See: https://stackoverflow.com/questions/66610586/openwebbeans-gives-error-java-lang-noclassdeffounderror-when-using-with-tomcat-1
371+
-->
356372
<dependency>
357-
<groupId>javax.annotation</groupId>
358-
<artifactId>javax.annotation-api</artifactId>
359-
<version>${javax-annotation-api}</version>
373+
<groupId>org.apache.openwebbeans</groupId>
374+
<artifactId>openwebbeans-se</artifactId>
375+
<version>${webbeans}</version>
376+
<classifier>jakarta</classifier>
360377
<scope>test</scope>
378+
<exclusions>
379+
<exclusion>
380+
<groupId>org.apache.openwebbeans</groupId>
381+
<artifactId>openwebbeans-impl</artifactId>
382+
</exclusion>
383+
<exclusion>
384+
<groupId>org.apache.openwebbeans</groupId>
385+
<artifactId>openwebbeans-spi</artifactId>
386+
</exclusion>
387+
</exclusions>
361388
</dependency>
362-
363389
<dependency>
364390
<groupId>org.apache.openwebbeans</groupId>
365-
<artifactId>openwebbeans-se</artifactId>
391+
<artifactId>openwebbeans-impl</artifactId>
392+
<version>${webbeans}</version>
393+
<classifier>jakarta</classifier>
394+
<scope>test</scope>
395+
</dependency>
396+
<dependency>
397+
<groupId>org.apache.openwebbeans</groupId>
398+
<artifactId>openwebbeans-spi</artifactId>
366399
<version>${webbeans}</version>
400+
<classifier>jakarta</classifier>
367401
<scope>test</scope>
368402
</dependency>
369403

src/main/asciidoc/jpa.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ int setFixedFirstnameFor(String firstname, String lastname);
573573
----
574574
====
575575

576-
Doing so triggers the query annotated to the method as an updating query instead of a selecting one. As the `EntityManager` might contain outdated entities after the execution of the modifying query, we do not automatically clear it (see the https://docs.oracle.com/javaee/7/api/javax/persistence/EntityManager.html[JavaDoc] of `EntityManager.clear()` for details), since this effectively drops all non-flushed changes still pending in the `EntityManager`.
576+
Doing so triggers the query annotated to the method as an updating query instead of a selecting one. As the `EntityManager` might contain outdated entities after the execution of the modifying query, we do not automatically clear it (see the https://jakarta.ee/specifications/persistence/2.2/apidocs/javax/persistence/entitymanager[JavaDoc] of `EntityManager.clear()` for details), since this effectively drops all non-flushed changes still pending in the `EntityManager`.
577577
If you wish the `EntityManager` to be cleared automatically, you can set the `@Modifying` annotation's `clearAutomatically` attribute to `true`.
578578

579579
The `@Modifying` annotation is only relevant in combination with the `@Query` annotation.

src/main/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilder.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
import java.util.Optional;
2222
import java.util.Set;
2323

24-
import javax.persistence.criteria.CriteriaBuilder;
25-
import javax.persistence.criteria.Expression;
26-
import javax.persistence.criteria.From;
27-
import javax.persistence.criteria.Path;
28-
import javax.persistence.criteria.Predicate;
29-
import javax.persistence.criteria.Root;
30-
import javax.persistence.metamodel.Attribute;
31-
import javax.persistence.metamodel.Attribute.PersistentAttributeType;
32-
import javax.persistence.metamodel.ManagedType;
33-
import javax.persistence.metamodel.SingularAttribute;
24+
import jakarta.persistence.criteria.CriteriaBuilder;
25+
import jakarta.persistence.criteria.Expression;
26+
import jakarta.persistence.criteria.From;
27+
import jakarta.persistence.criteria.Path;
28+
import jakarta.persistence.criteria.Predicate;
29+
import jakarta.persistence.criteria.Root;
30+
import jakarta.persistence.metamodel.Attribute;
31+
import jakarta.persistence.metamodel.Attribute.PersistentAttributeType;
32+
import jakarta.persistence.metamodel.ManagedType;
33+
import jakarta.persistence.metamodel.SingularAttribute;
3434

3535
import org.springframework.dao.InvalidDataAccessApiUsageException;
3636
import org.springframework.data.domain.Example;

src/main/java/org/springframework/data/jpa/convert/threeten/Jsr310JpaConverters.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import java.time.ZoneId;
2323
import java.util.Date;
2424

25-
import javax.persistence.AttributeConverter;
26-
import javax.persistence.Converter;
25+
import jakarta.persistence.AttributeConverter;
26+
import jakarta.persistence.Converter;
2727

2828
import org.springframework.data.convert.Jsr310Converters.DateToInstantConverter;
2929
import org.springframework.data.convert.Jsr310Converters.DateToLocalDateConverter;

src/main/java/org/springframework/data/jpa/domain/AbstractAuditable.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
import java.util.Date;
2222
import java.util.Optional;
2323

24-
import javax.persistence.ManyToOne;
25-
import javax.persistence.MappedSuperclass;
26-
import javax.persistence.Temporal;
27-
import javax.persistence.TemporalType;
24+
import jakarta.persistence.ManyToOne;
25+
import jakarta.persistence.MappedSuperclass;
26+
import jakarta.persistence.Temporal;
27+
import jakarta.persistence.TemporalType;
2828

2929
import org.springframework.data.domain.Auditable;
3030
import org.springframework.lang.Nullable;

src/main/java/org/springframework/data/jpa/domain/AbstractPersistable.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import java.io.Serializable;
1919

20-
import javax.persistence.GeneratedValue;
21-
import javax.persistence.Id;
22-
import javax.persistence.MappedSuperclass;
23-
import javax.persistence.Transient;
20+
import jakarta.persistence.GeneratedValue;
21+
import jakarta.persistence.Id;
22+
import jakarta.persistence.MappedSuperclass;
23+
import jakarta.persistence.Transient;
2424

2525
import org.springframework.data.domain.Persistable;
2626
import org.springframework.data.util.ProxyUtils;

src/main/java/org/springframework/data/jpa/domain/JpaSort.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import java.util.Collections;
2222
import java.util.List;
2323

24-
import javax.persistence.metamodel.Attribute;
25-
import javax.persistence.metamodel.PluralAttribute;
24+
import jakarta.persistence.metamodel.Attribute;
25+
import jakarta.persistence.metamodel.PluralAttribute;
2626

2727
import org.springframework.data.domain.Sort;
2828
import org.springframework.lang.Nullable;

src/main/java/org/springframework/data/jpa/domain/Specification.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import java.io.Serializable;
1919

20-
import javax.persistence.criteria.CriteriaBuilder;
21-
import javax.persistence.criteria.CriteriaQuery;
22-
import javax.persistence.criteria.Predicate;
23-
import javax.persistence.criteria.Root;
20+
import jakarta.persistence.criteria.CriteriaBuilder;
21+
import jakarta.persistence.criteria.CriteriaQuery;
22+
import jakarta.persistence.criteria.Predicate;
23+
import jakarta.persistence.criteria.Root;
2424

2525
import org.springframework.lang.Nullable;
2626

src/main/java/org/springframework/data/jpa/domain/SpecificationComposition.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import java.io.Serializable;
1919

20-
import javax.persistence.criteria.CriteriaBuilder;
21-
import javax.persistence.criteria.CriteriaQuery;
22-
import javax.persistence.criteria.Predicate;
23-
import javax.persistence.criteria.Root;
20+
import jakarta.persistence.criteria.CriteriaBuilder;
21+
import jakarta.persistence.criteria.CriteriaQuery;
22+
import jakarta.persistence.criteria.Predicate;
23+
import jakarta.persistence.criteria.Root;
2424

2525
import org.springframework.lang.Nullable;
2626

src/main/java/org/springframework/data/jpa/domain/support/AuditingBeanFactoryPostProcessor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
/**
2828
* {@link BeanFactoryPostProcessor} that ensures that the {@link AnnotationBeanConfigurerAspect} aspect is up and
29-
* running <em>before</em> the {@link javax.persistence.EntityManagerFactory} gets created as this already instantiates
29+
* running <em>before</em> the {@link jakarta.persistence.EntityManagerFactory} gets created as this already instantiates
3030
* entity listeners and we need to get injection into {@link org.springframework.beans.factory.annotation.Configurable}
3131
* to work in them.
3232
*

src/main/java/org/springframework/data/jpa/domain/support/AuditingEntityListener.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.springframework.data.jpa.domain.support;
1717

18-
import javax.persistence.PrePersist;
19-
import javax.persistence.PreUpdate;
18+
import jakarta.persistence.PrePersist;
19+
import jakarta.persistence.PreUpdate;
2020

2121
import org.springframework.beans.factory.ObjectFactory;
2222
import org.springframework.beans.factory.annotation.Configurable;

src/main/java/org/springframework/data/jpa/mapping/JpaMetamodelMappingContext.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import java.util.Set;
1919
import java.util.function.Predicate;
2020

21-
import javax.persistence.metamodel.ManagedType;
22-
import javax.persistence.metamodel.Metamodel;
21+
import jakarta.persistence.metamodel.ManagedType;
22+
import jakarta.persistence.metamodel.Metamodel;
2323

2424
import org.springframework.data.jpa.provider.PersistenceProvider;
2525
import org.springframework.data.jpa.util.JpaMetamodel;

src/main/java/org/springframework/data/jpa/mapping/JpaPersistentEntityImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class JpaPersistentEntityImpl<T> extends BasicPersistentEntity<T, JpaPersistentP
4141

4242
private static final String INVALID_VERSION_ANNOTATION = "%s is annotated with "
4343
+ org.springframework.data.annotation.Version.class.getName() + " but needs to use "
44-
+ javax.persistence.Version.class.getName() + " to trigger optimistic locking correctly!";
44+
+ jakarta.persistence.Version.class.getName() + " to trigger optimistic locking correctly!";
4545

4646
private final ProxyIdAccessor proxyIdAccessor;
4747
private final JpaMetamodel metamodel;

src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import java.util.HashSet;
2222
import java.util.Set;
2323

24-
import javax.persistence.*;
25-
import javax.persistence.metamodel.Metamodel;
24+
import jakarta.persistence.*;
25+
import jakarta.persistence.metamodel.Metamodel;
2626

2727
import org.springframework.core.annotation.AnnotationUtils;
2828
import org.springframework.data.annotation.AccessType.Type;

src/main/java/org/springframework/data/jpa/provider/JpaClassUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.springframework.data.jpa.provider;
1717

18-
import javax.persistence.EntityManager;
19-
import javax.persistence.metamodel.Metamodel;
18+
import jakarta.persistence.EntityManager;
19+
import jakarta.persistence.metamodel.Metamodel;
2020

2121
import org.springframework.lang.Nullable;
2222
import org.springframework.util.Assert;

src/main/java/org/springframework/data/jpa/provider/PersistenceProvider.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
import java.util.NoSuchElementException;
2323
import java.util.Set;
2424

25-
import javax.persistence.EntityManager;
26-
import javax.persistence.Query;
27-
import javax.persistence.metamodel.IdentifiableType;
28-
import javax.persistence.metamodel.Metamodel;
29-
import javax.persistence.metamodel.SingularAttribute;
25+
import jakarta.persistence.EntityManager;
26+
import jakarta.persistence.Query;
27+
import jakarta.persistence.metamodel.IdentifiableType;
28+
import jakarta.persistence.metamodel.Metamodel;
29+
import jakarta.persistence.metamodel.SingularAttribute;
3030

3131
import org.eclipse.persistence.jpa.JpaQuery;
3232
import org.eclipse.persistence.queries.ScrollableCursor;
@@ -110,7 +110,7 @@ public Object getIdentifierFrom(Object entity) {
110110

111111
/*
112112
* (non-Javadoc)
113-
* @see org.springframework.data.jpa.provider.PersistenceProvider#executeQueryWithResultStream(javax.persistence.Query)
113+
* @see org.springframework.data.jpa.provider.PersistenceProvider#executeQueryWithResultStream(jakarta.persistence.Query)
114114
*/
115115
@Override
116116
public CloseableIterator<Object> executeQueryWithResultStream(Query jpaQuery) {
@@ -150,7 +150,7 @@ public Object getIdentifierFrom(Object entity) {
150150

151151
/*
152152
* (non-Javadoc)
153-
* @see org.springframework.data.jpa.provider.PersistenceProvider#executeQueryWithResultStream(javax.persistence.Query)
153+
* @see org.springframework.data.jpa.provider.PersistenceProvider#executeQueryWithResultStream(jakarta.persistence.Query)
154154
*/
155155
@Override
156156
public CloseableIterator<Object> executeQueryWithResultStream(Query jpaQuery) {
@@ -165,7 +165,7 @@ public CloseableIterator<Object> executeQueryWithResultStream(Query jpaQuery) {
165165

166166
/*
167167
* (non-Javadoc)
168-
* @see org.springframework.data.jpa.repository.query.QueryExtractor#extractQueryString(javax.persistence.Query)
168+
* @see org.springframework.data.jpa.repository.query.QueryExtractor#extractQueryString(jakarta.persistence.Query)
169169
*/
170170
@Nullable
171171
@Override
@@ -328,7 +328,7 @@ public boolean canExtractQuery() {
328328
*/
329329
interface Constants {
330330

331-
String GENERIC_JPA_ENTITY_MANAGER_INTERFACE = "javax.persistence.EntityManager";
331+
String GENERIC_JPA_ENTITY_MANAGER_INTERFACE = "jakarta.persistence.EntityManager";
332332
String ECLIPSELINK_ENTITY_MANAGER_INTERFACE = "org.eclipse.persistence.jpa.JpaEntityManager";
333333
// needed as Spring only exposes that interface via the EM proxy
334334
String HIBERNATE_ENTITY_MANAGER_INTERFACE = "org.hibernate.jpa.HibernateEntityManager";

src/main/java/org/springframework/data/jpa/provider/QueryExtractor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.data.jpa.provider;
1717

18-
import javax.persistence.Query;
18+
import jakarta.persistence.Query;
1919

2020
import org.springframework.lang.Nullable;
2121

0 commit comments

Comments
 (0)