• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@ManyToMany - delete inverse side object

 
Aleksander Zielinski
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 ]
 
Shailesh Kini
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.
 
Edvins Reisons
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic