Bug 1182303 - (6.4.0) [HHH-9330] orphanRemoval=true does not work in bidirectional relationships (without cascading)
Summary: (6.4.0) [HHH-9330] orphanRemoval=true does not work in bidirectional relation...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate
Version: 6.3.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ER1
: EAP 6.4.0
Assignee: Gail Badner
QA Contact: Martin Simka
URL:
Whiteboard:
Depends On:
Blocks: 1173454 1182354
TreeView+ depends on / blocked
 
Reported: 2015-01-14 20:14 UTC by Gail Badner
Modified: 2015-02-04 06:41 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
: 1182354 (view as bug list)
Environment:
Last Closed: 2015-02-04 06:40:52 UTC
Type: Bug
Embargoed:
gbadner: needinfo+


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.