[hibernate-issues] [JIRA] (HHH-14079) Orphan removal does not work on session.update function

Ali Hopyar (JIRA) jira at hibernate.atlassian.net
Mon Jun 22 05:35:04 EDT 2020


Ali Hopyar ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Add96fccc-1289-4d99-810b-5723cdd171e2 ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2UzNjQzMTM4NTcyNGY3NWJkZjM1Mjk3MTRhN2Q2ZGMiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14079?atlOrigin=eyJpIjoiN2UzNjQzMTM4NTcyNGY3NWJkZjM1Mjk3MTRhN2Q2ZGMiLCJwIjoiaiJ9 ) HHH-14079 ( https://hibernate.atlassian.net/browse/HHH-14079?atlOrigin=eyJpIjoiN2UzNjQzMTM4NTcyNGY3NWJkZjM1Mjk3MTRhN2Q2ZGMiLCJwIjoiaiJ9 ) Orphan removal does not work on session.update function ( https://hibernate.atlassian.net/browse/HHH-14079?atlOrigin=eyJpIjoiN2UzNjQzMTM4NTcyNGY3NWJkZjM1Mjk3MTRhN2Q2ZGMiLCJwIjoiaiJ9 )

Change By: Ali Hopyar ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Add96fccc-1289-4d99-810b-5723cdd171e2 )

Let's say I have two entites like

{code:java}@Table(name = "parent_entity")
@Entity(name = "ParentEntity")
public class ParentEntity extends PersistentEntity {

@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "inner_entity")
private InnerEntity innerEntity = new InnerEntity();

public InnerEntity getInnerEntity() {
return innerEntity;
}

public void setInnerEntity(InnerEntity innerEntity) {
this.innerEntity = innerEntity;
}

}

@Table(name = "inner_entity")
@Entity(name = "InnerEntity")
public class InnerEntity extends PersistentEntity {

@OneToMany(mappedBy = "innerEntity", cascade = CascadeType.ALL, orphanRemoval = true)
private List<ChildEntity> children = new ArrayList<>();

public List<ChildEntity> getChildren() {
return children;
}

public void setChildren(List<ChildEntity> children) {
this.children = children;
}

}

@Table(name = "child_entity")
@Entity(name = "ChildEntity")
public class ChildEntity extends PersistentEntity {

@ManyToOne
@JoinColumn(name = "inner_entity")
private InnerEntity innerEntity;

@Column(name = "child_value")
private String childValue;

public InnerEntity getInnerEntity() {
return innerEntity;
}

public void setInnerEntity(InnerEntity innerEntity) {
this.innerEntity = innerEntity;
}

public String getChildValue() {
return childValue;
}

public void setChildValue(String childValue) {
this.childValue = childValue;
}
}
{code}

When I call session.update with parent entity, orphanRemoval does not have any affect. It does not delete child entity and relationship between parent and child.

I have tried with 5.3.7.Final, 5.4.15.Final, 5.4.16.Final and 5.4.17 Final

( https://hibernate.atlassian.net/browse/HHH-14079#add-comment?atlOrigin=eyJpIjoiN2UzNjQzMTM4NTcyNGY3NWJkZjM1Mjk3MTRhN2Q2ZGMiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14079#add-comment?atlOrigin=eyJpIjoiN2UzNjQzMTM4NTcyNGY3NWJkZjM1Mjk3MTRhN2Q2ZGMiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100130- sha1:10d2092 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200622/d7b7ebd1/attachment.html 


More information about the hibernate-issues mailing list