posted 14 years ago
...so I have the following two entities:
As you can see, every Customer can have one or zero bank accounts.
And the problematic code: I have created a customer and assigned abank account to it. Now I want to remove the bank account first, update the customer, and then I want to change the customer name.
The first update is done without problem, but during the second one I get the exception:
java.lang.IllegalArgumentException: Removing a detached instance Customer#262144
at org.hibernate.ejb.event.EJB3DeleteEventListener.performDetachedEntityDeletionCheck(EJB3DeleteEventListener.java:65)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:108)
at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:957)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:940)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:258)
at org.hibernate.engine.Cascade.cascade(Cascade.java:161)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:154)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:145)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:88)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)
... 44 more
What am I doing wrong?
And more important: what can I do to fix it?