Closed
Description
When using an JpaRepository with an compound IdClass the deleteAllByIdInBatch methods fails with an IllegalArgumentException like:
java.lang.IllegalArgumentException: Parameter value element [DeviceGroupDeviceLink.Key(deviceGroupId=8602858a-9ac9-4e70-b381-b2e3163a5b66, deviceId=8cb39b4b-3922-4b65-8150-c5566dc7ffb4)] did not match expected type [java.util.UUID (n/a)],[B@2408dbed,false,2022-01-21 15:08:40.358601)]
Below a test I added to org.springframework.data.jpa.repository.RepositoryWithCompositeKeyTests that fails also (on 2.6.x branch).
@Autowired EntityManager em;
@Test
void shouldSupportDeleteAllByIdInBatchWithIdClass() throws Exception {
IdClassExampleDepartment dep = new IdClassExampleDepartment();
dep.setName("TestDepartment");
dep.setDepartmentId(-1);
IdClassExampleEmployee emp = new IdClassExampleEmployee();
emp.setDepartment(dep);
emp = employeeRepositoryWithIdClass.save(emp);
IdClassExampleEmployeePK key = new IdClassExampleEmployeePK(emp.getEmpId(), dep.getDepartmentId());
assertThat(employeeRepositoryWithIdClass.findById(key)).isNotEmpty();
employeeRepositoryWithIdClass.deleteAllByIdInBatch(Arrays.asList(key));
em.flush();
em.clear();
assertThat(employeeRepositoryWithIdClass.findById(key)).isEmpty();
}
Could this be fixed and back ported to the 2.5 branch also? Because we are running Spring Boot 2.5.