Affects: v6.0.9
Since upgrading to Spring Boot 3.1.0 from 3.0.6 we are experiencing NPEs when calling .deleteAll() on Spring Data JPA repositories, but not for each entity. I suspect it is related to entities which contain lazy collections, but could not narrow it down further yet. It seems to only occur if the transaction calling .deleteAll has not previously modified the to-be-deleted entities. We were not able to reproduce the issue using only hibernate, but we were able to reproduce the issue using only spring-framework without spring-boot/spring-data, so it might be somehow related to spring-framework, even though the issue does not occur when downgrading hibernate to 6.1.7
Please also check out the original spring-boot issue: https://github.com/spring-projects/spring-boot/issues/35617
Sample-project: https://github.com/wilkinsona/spring-hibernate-bug-demo/tree/master
Comment From: jhoeller
As per my comment on the Boot issue, this does not appear to be related to Spring Framework's Hibernate JPA setup or transaction management but rather to the presence of a full Hibernate Validator setup with a Jakarta EL provider, with the validation lifecycle somehow not matching the state of Hibernate's internal persister for a lazy collection when checking its size: https://github.com/spring-projects/spring-boot/issues/35617#issuecomment-1562879390
All of this is internally detected and arranged by Hibernate ORM, with nothing that we can do about it from the outside.