• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue in deleting orphan in OneToOne relationship  RSS feed

Shihu Salam
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing an issue with orphan removal in hibernate.

Problem: I have an entity A, which has a one to one relation with entity B. I've used one to one annotation with orphan removal attribute ( @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) ). The associated entity B is referenced by other entities too. So while deleting entity A, I am getting constraint violation exception saying 'child record found'. I want to delete the associated entity to be deleted, if it is not referenced by other entities. If it has an existing association, I don't want to delete B, just A to be deleted.

Is there any way to do this, I am using hibernate 3.6.10. I read orphanRemoval will do the trick, But it didn't in my case.

Any help really appreciated..

Thanks !
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!