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 ;
47
48
* @author Thomas Darimont
48
49
* @author Mark Paluch
49
50
* @author Jens Schauder
51
+ * @author Ernst-Jan van der Laan
50
52
*/
51
53
@ ExtendWith (SpringExtension .class )
52
54
@ ContextConfiguration (classes = SampleConfig .class )
@@ -55,6 +57,7 @@ public class RepositoryWithCompositeKeyTests {
55
57
56
58
@ Autowired EmployeeRepositoryWithIdClass employeeRepositoryWithIdClass ;
57
59
@ Autowired EmployeeRepositoryWithEmbeddedId employeeRepositoryWithEmbeddedId ;
60
+ @ Autowired EntityManager em ;
58
61
59
62
/**
60
63
* @see <a href="download.oracle.com/otn-pub/jcp/persistence-2_1-fr-eval-spec/JavaPersistence.pdf">Final JPA 2.0
@@ -126,6 +129,28 @@ void shouldSupportFindAllWithPageableAndEntityWithIdClass() throws Exception {
126
129
assertThat (page .getTotalElements ()).isEqualTo (1L );
127
130
}
128
131
132
+ @ Test // DATAJPA-2414
133
+ void shouldSupportDeleteAllByIdInBatchWithIdClass () throws Exception {
134
+
135
+ IdClassExampleDepartment dep = new IdClassExampleDepartment ();
136
+ dep .setName ("TestDepartment" );
137
+ dep .setDepartmentId (-1 );
138
+
139
+ IdClassExampleEmployee emp = new IdClassExampleEmployee ();
140
+ emp .setDepartment (dep );
141
+ emp = employeeRepositoryWithIdClass .save (emp );
142
+
143
+ IdClassExampleEmployeePK key = new IdClassExampleEmployeePK (emp .getEmpId (), dep .getDepartmentId ());
144
+ assertThat (employeeRepositoryWithIdClass .findById (key )).isNotEmpty ();
145
+
146
+ employeeRepositoryWithIdClass .deleteAllByIdInBatch (Arrays .asList (key ));
147
+
148
+ em .flush ();
149
+ em .clear ();
150
+
151
+ assertThat (employeeRepositoryWithIdClass .findById (key )).isEmpty ();
152
+ }
153
+
129
154
@ Test // DATAJPA-497
130
155
void sortByEmbeddedPkFieldInCompositePkWithEmbeddedIdInQueryDsl () {
131
156
0 commit comments