After upgrading from version 3.5.5 to 3.5.6, a method that previously worked correctly now throws the following exception:
long count = reqRepo.deleteAllByCreatedAtBefore(now.plusMinutes(1L));
org.springframework.dao.IncorrectResultSizeDataAccessException:
Delete query returned more than one element: expected 1, actual 5
This seems to indicate that the delete operation is unexpectedly returning multiple results, whereas only one was expected. This behavior was not present in 3.5.5.
Code
@Test
void testDeleteAllByCreatedAtBefore(){
var now = ZonedDateTime.now();
List<RestData> data = createRestDataList();
reqRepo.saveAll(data);
reqRepo.flush();
Assertions.assertEquals(5, reqRepo.findAll().size());
long count = reqRepo.deleteAllByCreatedAtBefore(now.plusMinutes(1L));
Assertions.assertEquals(5, count);
Assertions.assertEquals(0, reqRepo.findAll().size());
}
Comment From: bclozel
I think this duplicates https://github.com/spring-projects/spring-data-jpa/issues/4015