Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cascade Type Question

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two tables Table A and Table B, Table A has a One to many relationship to be. I would like to delete a row in Table B, But anytime i delete that row, it also deletes
the parent row in Table A


Currently i am using




I am using a CascadeType.ALL

Any ideas?
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know if it would help but why not have a @OneToMany from A to B instead?
 
Aparna Raghavan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the cascade={CascadeType.ALL} it will work
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think i am missing something here...
we have a table A and that has one to many relationship with B.
ie an A corresponds to many B.
if we happen to delete a record from B, it deletes the parent from A.
That means the other records in B dont have a parent, ie, the foreign key is violated.
I dont think that is possible, is it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic