It is very difficult to provide help without a test case that demonstrates the problem.
Please look at the following test case:
import java.util.*;
import javax.persistence.*;
public final class T1473
{
static java.sql.Date myDate;
public static void main(String[] args) {
EntityManagerFactory emf =
Persistence.createEntityManagerFactory(
"objectdb:$objectdb/db/test.tmp;drop");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
MyEntity e = new MyEntity(1);
e.myCollection.add(new MyEntity(2));
e.myCollection.add(new MyEntity(3));
em.persist(e);
em.getTransaction().commit();
em.close();
em = emf.createEntityManager();
e = em.find(MyEntity.class, 1);
em.getTransaction().begin();
e.myCollection.add(new MyEntity(4));
em.getTransaction().commit();
em.close();
emf.close();
}
@Entity
public static class MyEntity {
@Id int id;
@OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST)
List<MyEntity> myCollection = new ArrayList<MyEntity>();
MyEntity(int id) {
this.id = id;
}
@PostUpdate
public void postUpdate() {
System.out.println(myCollection.size());
}
}
}
The postUpdate method is invoked as expected and the output is 3.
You may try to modify this test in order the demonstrate the issue that you have.