JAVA-28958 :- Upgrade spring-data-jpa-repo-2 to Spring Boot 3 (#15826)

* Initial Commit

* JAVA-28958 :- Upgrade to Spring Boot 3 for spring-data-jpa-repo-2.

* JAVA-28958 :- Delete unnecessary properties.

* JAVA-28958 :- Add property in POM.
This commit is contained in:
Amit Pandey 2024-02-12 05:11:10 +05:30 committed by GitHub
parent 4a229ecfe5
commit 5b86742881
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 70 additions and 63 deletions

View File

@ -8,9 +8,9 @@
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId> <artifactId>parent-boot-3</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-2</relativePath> <relativePath>../../parent-boot-3</relativePath>
</parent> </parent>
<dependencies> <dependencies>
@ -19,8 +19,9 @@
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.persistence</groupId> <groupId>jakarta.persistence</groupId>
<artifactId>javax.persistence-api</artifactId> <artifactId>jakarta.persistence-api</artifactId>
<version>${jakarta.persistence.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
@ -29,6 +30,16 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</exclusion>
<exclusion>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
@ -36,33 +47,21 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.querydsl</groupId> <groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId> <artifactId>querydsl-jpa</artifactId>
<classifier>jakarta</classifier>
<version>${querydsl.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.querydsl</groupId> <groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId> <artifactId>querydsl-apt</artifactId>
<classifier>jakarta</classifier>
<version>${querydsl.version}</version>
<scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.bsc.maven</groupId> <groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId> <artifactId>maven-processor-plugin</artifactId>
@ -86,11 +85,21 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId> <artifactId>hibernate-jpamodelgen</artifactId>
<version>5.6.11.Final</version> <version>${hibernate-jpamodelgen.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<querydsl.version>5.0.0</querydsl.version>
<jakarta.persistence.version>3.1.0</jakarta.persistence.version>
<apt-maven-plugin.version>1.1.3</apt-maven-plugin.version>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
<hibernate-jpamodelgen.version>6.4.2.Final</hibernate-jpamodelgen.version>
</properties>
</project> </project>

View File

@ -1,8 +1,8 @@
package com.baeldung.spring.data.persistence.customrepository.model; package com.baeldung.spring.data.persistence.customrepository.model;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import java.util.Objects; import java.util.Objects;
@Entity @Entity

View File

@ -2,9 +2,9 @@ package com.baeldung.spring.data.persistence.customrepository.repository;
import com.baeldung.spring.data.persistence.customrepository.model.User; import com.baeldung.spring.data.persistence.customrepository.model.User;
import javax.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import java.util.Objects; import java.util.Objects;
public class CustomUserRepositoryImpl implements CustomUserRepository { public class CustomUserRepositoryImpl implements CustomUserRepository {

View File

@ -1,9 +1,9 @@
package com.baeldung.spring.data.persistence.findbyvsfindallby.model; package com.baeldung.spring.data.persistence.findbyvsfindallby.model;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.GenerationType; import jakarta.persistence.GenerationType;
import javax.persistence.Id; import jakarta.persistence.Id;
import java.util.Objects; import java.util.Objects;
@Entity @Entity

View File

@ -1,9 +1,9 @@
package com.baeldung.spring.data.persistence.saveperformance; package com.baeldung.spring.data.persistence.saveperformance;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.GenerationType; import jakarta.persistence.GenerationType;
import javax.persistence.Id; import jakarta.persistence.Id;
@Entity @Entity
public class Book { public class Book {

View File

@ -2,10 +2,10 @@ package com.baeldung.spring.data.persistence.search;
import java.util.Objects; import java.util.Objects;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.GenerationType; import jakarta.persistence.GenerationType;
import javax.persistence.Id; import jakarta.persistence.Id;
@Entity @Entity
public class Student { public class Student {

View File

@ -3,13 +3,13 @@ package com.baeldung.spring.data.persistence.springdatajpadifference.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.GenerationType; import jakarta.persistence.GenerationType;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.NamedQuery; import jakarta.persistence.NamedQuery;
import javax.persistence.Table; import jakarta.persistence.Table;
@Entity @Entity
@Table(name = "employee") @Table(name = "employee")

View File

@ -2,7 +2,7 @@ package com.baeldung.spring.data.persistence.springdatajpadifference.springdata.
import java.util.Properties; import java.util.Properties;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.jdbc.DataSourceBuilder;

View File

@ -1,11 +1,11 @@
package com.baeldung.spring.data.persistence.springdatajpadifference.springdata.repository; package com.baeldung.spring.data.persistence.springdatajpadifference.springdata.repository;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.baeldung.spring.data.persistence.springdatajpadifference.model.Employee; import com.baeldung.spring.data.persistence.springdatajpadifference.model.Employee;
@Repository @Repository
public interface EmployeeRepositoryPagingAndSort extends PagingAndSortingRepository<Employee, Long> { public interface EmployeeRepositoryPagingAndSort extends JpaRepository<Employee, Long> {
} }

View File

@ -13,8 +13,6 @@ import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;

View File

@ -7,15 +7,15 @@ import static org.junit.Assert.assertNull;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import jakarta.persistence.EntityManagerFactory;
import javax.persistence.Persistence; import jakarta.persistence.Persistence;
import javax.persistence.Query; import jakarta.persistence.Query;
import javax.persistence.TypedQuery; import jakarta.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import jakarta.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.CriteriaUpdate; import jakarta.persistence.criteria.CriteriaUpdate;
import javax.persistence.criteria.Root; import jakarta.persistence.criteria.Root;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;