Cristina Belderrain wrote:
Full stack trace of any exception that occurs:
Exception in thread "main" javax.persistence.RollbackException: Error while commiting the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
at operations.facade.CRUDService.execTransaction(CRUDService.java:54)
at operations.facade.CRUDService.delete(CRUDService.java:42)
at operations.client.SampleClient.accessDB(SampleClient.java:89)
at operations.client.SampleClient.main(SampleClient.java:38)
Caused by: org.hibernate.ObjectDeletedException: deleted entity passed to persist: [operations.domain.core.Employee#<null>]
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:90)
...
Hello,
I've managed to avoid the above exception by ensuring the Model Facade which wraps EntityManager's remove() method is declared as a *private static final* class variable in every client of the Facade's services. I don't know why such a change avoids the exception: besides being apparently unrelated to the problem I've described, it has been implemented as a response to another kind of exception.
This doesn't mean, however, that I'm now able to always delete subtype records: some records can be deleted, some can't, even though the delete transaction is reported as successful and no exceptions are thrown. If the undeletable records aren't inserted when the test DB is loaded, other records that previously could be deleted just won't be deleted anymore.
Cristina