• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on Cascades

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a small doubt on using cascades. Imagine I have an Entity called Questions and another entity called Choices and in the Choices entity, I have the QuestionId as the foreign key and in my mapping xml file for Questions and Choices, I do not specify anything for cascade. What will happen when I issue a delete statement on the Questions object?? will the command be propogated to the Choices table as well?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have no cascade option set, and you try to delete the parent, then you will get a constraint error from the database. As long as a FK is declared in the child table.

Mark
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark. I figured that out yesterday!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic