2020import java .util .Arrays ;
2121import java .util .List ;
2222
23+ import javax .persistence .EntityManager ;
24+
2325import org .junit .jupiter .api .Test ;
2426import org .junit .jupiter .api .extension .ExtendWith ;
25-
2627import org .springframework .beans .factory .annotation .Autowired ;
2728import org .springframework .data .domain .Page ;
2829import org .springframework .data .domain .PageRequest ;
4748 * @author Thomas Darimont
4849 * @author Mark Paluch
4950 * @author Jens Schauder
51+ * @author Ernst-Jan van der Laan
5052 */
5153@ ExtendWith (SpringExtension .class )
5254@ ContextConfiguration (classes = SampleConfig .class )
@@ -55,6 +57,7 @@ public class RepositoryWithCompositeKeyTests {
5557
5658 @ Autowired EmployeeRepositoryWithIdClass employeeRepositoryWithIdClass ;
5759 @ Autowired EmployeeRepositoryWithEmbeddedId employeeRepositoryWithEmbeddedId ;
60+ @ Autowired EntityManager em ;
5861
5962 /**
6063 * @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 {
126129 assertThat (page .getTotalElements ()).isEqualTo (1L );
127130 }
128131
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+
129154 @ Test // DATAJPA-497
130155 void sortByEmbeddedPkFieldInCompositePkWithEmbeddedIdInQueryDsl () {
131156
0 commit comments