Skip to content

NullPointerException during JPA delete with lazy collections #30542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pwandl opened this issue May 25, 2023 · 1 comment
Closed

NullPointerException during JPA delete with lazy collections #30542

pwandl opened this issue May 25, 2023 · 1 comment
Labels
for: external-project Needs a fix in external project in: data Issues in data modules (jdbc, orm, oxm, tx) status: invalid An issue that we don't feel is valid

Comments

@pwandl
Copy link

pwandl commented May 25, 2023

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:
spring-projects/spring-boot#35617

Sample-project:
https://github.com/wilkinsona/spring-hibernate-bug-demo/tree/master

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 25, 2023
@sbrannen sbrannen added the in: data Issues in data modules (jdbc, orm, oxm, tx) label May 25, 2023
@jhoeller
Copy link
Contributor

jhoeller commented May 25, 2023

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:
spring-projects/spring-boot#35617 (comment)

All of this is internally detected and arranged by Hibernate ORM, with nothing that we can do about it from the outside.

@jhoeller jhoeller added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 25, 2023
@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2023
@sbrannen sbrannen added the for: external-project Needs a fix in external project label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project Needs a fix in external project in: data Issues in data modules (jdbc, orm, oxm, tx) status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants