Israel Rios (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjc3N2IwMGU0...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16334?atlOrigin=eyJpIjoiNjc3N2...
) HHH-16334 (
https://hibernate.atlassian.net/browse/HHH-16334?atlOrigin=eyJpIjoiNjc3N2...
) Persist and load an entity with an all-delete-orphan collection null (
https://hibernate.atlassian.net/browse/HHH-16334?atlOrigin=eyJpIjoiNjc3N2...
)
Change By: Israel Rios (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
When persisting ant entity *Parent* with a collection *children,* mapped as
*all-delete-orphan,* set to null and then loading the same entity in a query results in:
org.hibernate.HibernateException: A collection with cascade="all-delete-orphan"
was no longer referenced by the owning entity instance:
org.hibernate.bugs.domain.Parent.children
Sample code:
{code:java}@Entity
public class Parent {
@Id
@GeneratedValue
private Long id;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval =
true)
private List<Child> children;
} {code}
{code:java}@Entity
public class Child {
@Id
@GeneratedValue
private Long id;
@ManyToOne
private Parent parent;
} {code}
Persisting and querying:
{code:java} var p = new Parent();
entityManager.persist(p);
for (var parent : entityManager.createQuery("from Parent",
Parent.class).getResultList()) {
System.out.println(parent.getChildren());
}{code}
Test case attached.
(
https://hibernate.atlassian.net/browse/HHH-16334#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16334#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#100218- sha1:9826a04 )