Peter Raupp (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=630c5e1...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMjZjM2M5ODQ0...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15469?atlOrigin=eyJpIjoiMjZjM2...
) HHH-15469 (
https://hibernate.atlassian.net/browse/HHH-15469?atlOrigin=eyJpIjoiMjZjM2...
) Missing EntityNotFoundException while using @ManyToOne / @OneToMany and EntityManager
interface (
https://hibernate.atlassian.net/browse/HHH-15469?atlOrigin=eyJpIjoiMjZjM2...
)
Change By: Peter Raupp (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=630c5e1...
)
When using Hibernate Session to remove a ManyToOne Child Entity, EntityNotFoundException
will raise up.
{code:java}
jakarta.persistence.EntityNotFoundException: deleted object would be re-saved by cascade
(remove deleted object from associations):
[org.hibernate.bugs.entities.Entity2#2_1 ]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:133)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:175)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:182)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1426)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1408)
at org.hibernate.bugs.ORMUnitTestCase.removeEntity2_1(ORMUnitTestCase.java:78)
{code}
If the EntityManager is used instead, *the exception will not be thrown*. Therefore the
Session.remove() call has no effect because the entity is saved again via cascading.
ORM Testcase sample based on hibernate-test-case-template can be found here: [
https://github.com/PeRaVs/hibernate-sample |https://github.com/PeRaVs/hibernate-sample]
Look at ORMUnitTestCase. java testcase ( ) ( based on Session class, with
EntityNotFoundException raised up)
Look at JPAUnitTestCase. java test ( ) ( based on EntityManager, without
EntityNotFoundException)
(
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#100206- sha1:5148740 )