Bug 1182354

Summary: (6.3.z) [HHH-9330] orphanRemoval=true does not work in bidirectional relationships (without cascading)
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Carlo de Wolf <cdewolf>
Component: HibernateAssignee: Gail Badner <gbadner>
Status: CLOSED WONTFIX QA Contact: Martin Simka <msimka>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: cdewolf, gbadner, msimka, smarlow
Target Milestone: CR1   
Target Release: EAP 6.3.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1182303 Environment:
Last Closed: 2015-01-21 21:39:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1182303    
Bug Blocks: 1151405, 1159890    

Description Carlo de Wolf 2015-01-14 22:45:32 UTC
+++ This bug was initially created as a clone of Bug #1182303 +++

Description of problem:

@Entity
public class Product {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;

	@OneToMany(mappedBy = "product", orphanRemoval = true)
	private List<Feature> features = new ArrayList<Feature>();
	...
}

@Entity
public class Feature { 
	@Id 
	@GeneratedValue(strategy=GenerationType.AUTO) 
	private Long id; 

	@ManyToOne() 
	private Product product;
	...
}

This affects EntityManager only. 

https://hibernate.atlassian.net/browse/HHH-9330

How reproducible: easy to reproduce.

Steps to Reproduce:
See the tests in org.hibernate.ejb.test.orphan.onetomany.DeleteOneToManyOrphansTest for details.

Actual results:
Clearing the collection of features in the Product will not result in deleting all Features of that product.

Expected results:
Features that were cleared should be deleted.

Additional info:

The workaround is setting the CascadeType.PERSIST in the Product entity.

Tests (which work properly) for Hibernate core are in org.hibernate.test.orphan.onetomany.DeleteOneToManyOrphansTest.

--- Additional comment from Gail Badner on 2015-01-14 21:55:56 CET ---

This was fixed in 4.2.17.Final.