• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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 !
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!