• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

@ManyToMany - delete inverse side object

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic