Israel Rios (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYmIzNWI5ZWMy...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16334?atlOrigin=eyJpIjoiYmIzNW...
) HHH-16334 (
https://hibernate.atlassian.net/browse/HHH-16334?atlOrigin=eyJpIjoiYmIzNW...
) Persist and load an entity with an all-delete-orphan collection null (
https://hibernate.atlassian.net/browse/HHH-16334?atlOrigin=eyJpIjoiYmIzNW...
)
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Unassigned Attachments:
hibernate6-collection-null-bug.tar.bz2 Components: hibernate-core Created: 17/Mar/2023
07:42 AM Environment: jvm 18 Priority: Major Reporter: 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:
@Entity
public class Parent {
@Id
@GeneratedValue
private Long id;
@OneToMany(mappedBy = "parent" , cascade = CascadeType.ALL, orphanRemoval =
true )
private List<Child> children;
@Entity
public class Child {
@Id
@GeneratedValue
private Long id;
@ManyToOne
private Parent parent;
var p = new Parent();
entityManager.persist(p);
for ( var parent : entityManager.createQuery( "from Parent" ,
Parent.class).getResultList()) {
System.out.println(parent.getChildren());
}
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 )