Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1182303

Summary: (6.4.0) [HHH-9330] orphanRemoval=true does not work in bidirectional relationships (without cascading)
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Gail Badner <gbadner>
Component: HibernateAssignee: Gail Badner <gbadner>
Status: CLOSED WONTFIX QA Contact: Martin Simka <msimka>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3.3CC: cdewolf, dosoudil, gbadner, jawilson, msimka, smarlow
Target Milestone: ER1Flags: gbadner: needinfo+
Target Release: EAP 6.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1182354 (view as bug list) Environment:
Last Closed: 2015-02-04 06:40:52 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:    
Bug Blocks: 1173454, 1182354    

Description Gail Badner 2015-01-14 20:14:08 UTC
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.

Comment 1 Gail Badner 2015-01-14 20:55:56 UTC
This was fixed in 4.2.17.Final.

Comment 3 Martin Simka 2015-01-28 13:44:43 UTC
failed QA due to BZ1182334