posted 12 years ago
In the below example, i am having ManyToOne relationship from Address to my parent entity Person. Now i am required to set the corresponding foreign key reference in my Person table as null whenever i delete an entry from the Address table.
I am using JPA 2.0 EntityManager.delete(addressEntity) method to delete the Address entity. But i am stuck up with the following exception. Neither my Address entity nor my reference key changed as null in Person table.
Please help me in solving the above said problem.
javax.persistence.RollbackException: Error while committing the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:93)
....
Caused by: javax.persistence.EntityNotFoundException: deleted entity passed to persist: [Person#<null>]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1197)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1148)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:81)
... 3 more
Thanks,
Akhil