Hi,
I have a @OneToMany relationship Order->OrderItem with CascadeType.ALL. I use JPA EntityManager, implementation is Hibernate 3.3. When I manipulate the List of OrderItem, then it works fine when I call em.merge(order). However, when I just remove some OrderItem from the List by calling
em.remove(orderItem); em.flush();
then I have got: javax.persistence.EntityNotFoundException: deleted entity passed to persist: [...OrderItem#<null>] But in this situation, I do not call any other em.merge(), or em.persist(). I have found a workaround: I have to call
em.remove(orderItem); order.getOrderItems().clear(); em.flush();
But I do not understand, why I should clear OrderItem List before flushing the EntitytManager. Is this a Hibernate bug?
Thanks Andy
|