• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Issue in deleting orphan in OneToOne relationship  RSS feed

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 !
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!