[JAVA-29499] Upgraded spring-data-jpa-query to spring boot 3 (#15774)
This commit is contained in:
parent
0fd2723ce2
commit
8fa19c0930
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue