I’ve defined all foreign keys and cascade operations in MySQL, should I also map then in hibernate objects or leave MySQL do it’s things alone?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are going to define them within your DB then defining them on your Hibernate objects really will just generate extra delete statements that really aren’t necessary.
Personally I think that having cascading deletes within a DB can be very difficult to work with as your DB has more of the intelligence of your application. I prefer to define these types of business rules within code rather than in the DB because it keeps all of your persistence information in one place. I think it’s a similar argument as to why many people dislike DB triggers.