• 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

@ManyToMany - delete inverse side object

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

Have a problem with deleting records. When trying to delete inverse side object (Car) and this object's key is used is in join table, it says children were found and operation is not possible. If I set cascade type to REMOVE on "drivers" collection it Car class, it also tries to delete associated Drivers what I don't want.

Is there any way to delete Car and all records in join table that reffers to this Car without deleting Driver?

Will be very grateful for help.






[ August 21, 2007: Message edited by: Aleksander Zielinski ]
[ August 21, 2007: Message edited by: Aleksander Zielinski ]
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aleksander,

You have an interesting problem at hand. I have never tried this out myself and I am not sure if cascade delete would work in this case. In my opinion one workaround is to use JPA QL to delete the records in your join table.

Please let us know if you find something more elegant.
 
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the owning side of the relationship is the Driver, it is from the Driver's collection that you need to remove the Driver-Car link.
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic