• 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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 !
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!