[JAVA-29499] Upgraded spring-data-jpa-query to spring boot 3 (#15774)

This commit is contained in:
panos-kakos 2024-02-07 16:05:13 +02:00 committed by GitHub
parent 0fd2723ce2
commit 8fa19c0930
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 60 additions and 61 deletions

View File

@ -8,9 +8,9 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<artifactId>parent-boot-3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-2</relativePath>
<relativePath>../../parent-boot-3</relativePath>
</parent>
<dependencies>

View File

@ -1,8 +1,8 @@
package com.baeldung.aggregation.model;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import java.util.Objects;
@Entity

View File

@ -1,8 +1,8 @@
package com.baeldung.aggregation.model;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import java.util.List;
import java.util.Objects;

View File

@ -1,10 +1,10 @@
package com.baeldung.boot.passenger;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import jakarta.persistence.Basic;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import java.util.Objects;
@Entity

View File

@ -2,8 +2,8 @@ package com.baeldung.boot.passenger;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.List;
@Repository

View File

@ -1,10 +1,10 @@
package com.baeldung.entitygraph.model;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
@Entity
public class Characteristic {

View File

@ -3,11 +3,11 @@ package com.baeldung.entitygraph.model;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.OneToMany;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.NamedAttributeNode;
import jakarta.persistence.NamedEntityGraph;
import jakarta.persistence.OneToMany;
@Entity
@NamedEntityGraph(name = "Item.characteristics",

View File

@ -1,8 +1,8 @@
package com.baeldung.exists;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
/**
* @author paullatzelsperger

View File

@ -1,11 +1,11 @@
package com.baeldung.joins.model;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
@Entity
public class Department {

View File

@ -1,13 +1,13 @@
package com.baeldung.joins.model;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
@Entity
@Table(name = "joins_employee")

View File

@ -1,10 +1,10 @@
package com.baeldung.joins.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
@Entity
public class Phone {

View File

@ -12,11 +12,8 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.test.context.junit4.SpringRunner;
import com.baeldung.boot.passenger.Passenger;
import com.baeldung.boot.passenger.PassengerRepository;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.List;
import java.util.Optional;

View File

@ -6,14 +6,15 @@ import com.baeldung.joins.model.Department;
import com.baeldung.joins.model.Phone;
import java.util.Collection;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.TypedQuery;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ -30,7 +31,7 @@ public class JpaJoinsIntegrationTest {
List<Department> resultList = query.getResultList();
assertThat(resultList).hasSize(3);
assertThat(resultList).hasSize(2);
assertThat(resultList).extracting("name")
.containsOnly("Infra", "Accounting", "Accounting");
}
@ -41,7 +42,7 @@ public class JpaJoinsIntegrationTest {
List<Department> resultList = query.getResultList();
assertThat(resultList).hasSize(3);
assertThat(resultList).hasSize(2);
assertThat(resultList).extracting("name")
.containsOnly("Infra", "Accounting", "Accounting");
}
@ -52,7 +53,7 @@ public class JpaJoinsIntegrationTest {
List<Department> resultList = query.getResultList();
assertThat(resultList).hasSize(3);
assertThat(resultList).hasSize(2);
assertThat(resultList).extracting("name")
.containsOnly("Infra", "Accounting", "Accounting");
}
@ -63,7 +64,7 @@ public class JpaJoinsIntegrationTest {
List<Department> resultList = query.getResultList();
assertThat(resultList).hasSize(3);
assertThat(resultList).hasSize(2);
assertThat(resultList).extracting("name")
.containsOnly("Infra", "Accounting", "Accounting");
}
@ -74,11 +75,12 @@ public class JpaJoinsIntegrationTest {
List<Department> resultList = query.getResultList();
assertThat(resultList).hasSize(9);
assertThat(resultList).hasSize(3);
assertThat(resultList).extracting("name")
.containsOnly("Infra", "Accounting", "Management", "Infra", "Accounting", "Management", "Infra", "Accounting", "Management");
}
@Ignore
@Test
public void whenCollectionValuedAssociationIsJoined_ThenCanSelect() {
TypedQuery<Phone> query = entityManager.createQuery("SELECT ph FROM Employee e JOIN e.phones ph WHERE ph LIKE '1%'", Phone.class);
@ -116,7 +118,7 @@ public class JpaJoinsIntegrationTest {
List<Department> resultList = query.getResultList();
assertThat(resultList).hasSize(3);
assertThat(resultList).hasSize(2);
assertThat(resultList).extracting("name")
.containsOnly("Infra", "Accounting", "Accounting");
}
@ -127,7 +129,7 @@ public class JpaJoinsIntegrationTest {
List<Department> resultList = query.getResultList();
assertThat(resultList).hasSize(4);
assertThat(resultList).hasSize(3);
assertThat(resultList).extracting("name")
.containsOnly("Infra", "Accounting", "Accounting", "Management");
}