|
20 | 20 | import java.util.Arrays;
|
21 | 21 | import java.util.List;
|
22 | 22 |
|
| 23 | +import javax.persistence.EntityManager; |
| 24 | + |
23 | 25 | import org.junit.jupiter.api.Test;
|
24 | 26 | import org.junit.jupiter.api.extension.ExtendWith;
|
25 |
| - |
26 | 27 | import org.springframework.beans.factory.annotation.Autowired;
|
27 | 28 | import org.springframework.data.domain.Page;
|
28 | 29 | import org.springframework.data.domain.PageRequest;
|
@@ -55,6 +56,7 @@ public class RepositoryWithCompositeKeyTests {
|
55 | 56 |
|
56 | 57 | @Autowired EmployeeRepositoryWithIdClass employeeRepositoryWithIdClass;
|
57 | 58 | @Autowired EmployeeRepositoryWithEmbeddedId employeeRepositoryWithEmbeddedId;
|
| 59 | + @Autowired EntityManager em; |
58 | 60 |
|
59 | 61 | /**
|
60 | 62 | * @see <a href="download.oracle.com/otn-pub/jcp/persistence-2_1-fr-eval-spec/JavaPersistence.pdf">Final JPA 2.0
|
@@ -126,6 +128,28 @@ void shouldSupportFindAllWithPageableAndEntityWithIdClass() throws Exception {
|
126 | 128 | assertThat(page.getTotalElements()).isEqualTo(1L);
|
127 | 129 | }
|
128 | 130 |
|
| 131 | + @Test |
| 132 | + void shouldSupportDeleteAllByIdInBatchWithIdClass() throws Exception { |
| 133 | + |
| 134 | + IdClassExampleDepartment dep = new IdClassExampleDepartment(); |
| 135 | + dep.setName("TestDepartment"); |
| 136 | + dep.setDepartmentId(-1); |
| 137 | + |
| 138 | + IdClassExampleEmployee emp = new IdClassExampleEmployee(); |
| 139 | + emp.setDepartment(dep); |
| 140 | + emp = employeeRepositoryWithIdClass.save(emp); |
| 141 | + |
| 142 | + IdClassExampleEmployeePK key = new IdClassExampleEmployeePK(emp.getEmpId(), dep.getDepartmentId()); |
| 143 | + assertThat(employeeRepositoryWithIdClass.findById(key)).isNotEmpty(); |
| 144 | + |
| 145 | + employeeRepositoryWithIdClass.deleteAllByIdInBatch(Arrays.asList(key)); |
| 146 | + |
| 147 | + em.flush(); |
| 148 | + em.clear(); |
| 149 | + |
| 150 | + assertThat(employeeRepositoryWithIdClass.findById(key)).isEmpty(); |
| 151 | + } |
| 152 | + |
129 | 153 | @Test // DATAJPA-497
|
130 | 154 | void sortByEmbeddedPkFieldInCompositePkWithEmbeddedIdInQueryDsl() {
|
131 | 155 |
|
|
0 commit comments