Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Lifecycle callbacks (preRemove, postRemove) not called on orphan removal
icon4.gif  Lifecycle callbacks (preRemove, postRemove) not called on orphan removal [message #1233250] Sun, 19 January 2014 03:19
Raffael Bachmann is currently offline Raffael BachmannFriend
Messages: 2
Registered: June 2013
Junior Member

My problem is that the @preRemove and @postRemove functions are not called when the entity is removed because of the "orphanRemoval = true" parameter in a relation.
I think this is a bug, but in the jpa spec i haven't found a statement that actually states that the life cycle callbacks must be called after orphan removal.
So I'd like to know if i should file a bug on this?
It is quite simple to test with two classes and a simple test case. I added a maven project containing everything needed. Changing the jpa provider in the pom.xml (dependency is just commented out) shows that the behavior is different with openjpa and hibernate.
Here the most important parts to demonstrate the problem.

public class A {
	private int id;

	@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
	private List<B> bs = new ArrayList<B>();

	public A() {}

	public A(int id) { = id;

	public List<B> getBs() {
		return bs;

public class B {
	private int id;

	private boolean preRemoveCalled = false;

	public void prepareRemove() {
		preRemoveCalled = true;

	public B() {}

	public B(int id) { = id;

	public boolean isPreRemoveCalled() {
		return preRemoveCalled;


public void testWithOrphanRemoal() {
	EntityTransaction et = em.getTransaction();
	try {
		A a1 = new A(1);
		B b1 = new B(1);
		// This fails with eclipseLink but works with openjpa and hibernate
	} finally {
Previous Topic:Problem with eclipselink, pagination, join fetch, field name alias
Next Topic:Eclipselink
Goto Forum:

Current Time: Thu Dec 18 22:25:57 GMT 2014

Powered by FUDForum. Page generated in 0.02011 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software