Christian Beikov (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-15469 (
https://hibernate.atlassian.net/browse/HHH-15469?atlOrigin=eyJpIjoiMmZiYW...
)
Re: Missing EntityNotFoundException while using @ManyToOne / @OneToMany and EntityManager
interface (
https://hibernate.atlassian.net/browse/HHH-15469?atlOrigin=eyJpIjoiMmZiYW...
)
When booting Hibernate through JPA APIs, it will use CascadingActions.PERSIST_ON_FLUSH for
cascading, and CascadingActions.SAVE_UPDATE if booted up through Hibernate native APIs.
According to the semantics of JPA, calling persist with a REMOVED entity will result in
the entity becoming managed again. See
https://jakarta.ee/specifications/persistence/3.1/jakarta-persistence-spe...
and
https://jakarta.ee/specifications/persistence/3.1/jakarta-persistence-spe...
I don’t know if the behavior of the saveOrUpdate operation for such a case is documented
anywhere, but it seems to me that it always was this way. You wrote that it “worked” in
5.6.7, but I tried that version and it didn’t. Hibernate throws the same exception with
that version.
So as far as I can tell, this works as designed and the only bug is in your code, because
a cascading association refers to an entity that is marked as removed.
(
https://hibernate.atlassian.net/browse/HHH-15469#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15469#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100233- sha1:7fb7fe8 )