Performance is key: Is it better to cascade deletes/updates inside of the Database or let Hibernate/JPA take care of it?
Will this effect the ability to query for the data if cascades are inside of the DBMS?
I am using HSQLDB if that matters.
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.
In the case of cascading updates, you simply cannot do it in application space if you have foreign key constraints in the database.
Example: say you have a lookup table for US states, with a primary key of the two-letter abbreviation. Then you have a table for mailing addresses that references it. Someone tells you that you mistakenly gave Montana the abbreviation ‘MO’ instead of ‘MT’ so you need to change it in the lookup table.
Now you go to fix the mistake, without the aid of database-side cascading updates. Below is a test using MySQL 5.0 (assume no records exist for Missouri, which actually does use the abbreviation ‘MO’).
No application-side query can solve this situation. You need cascading updates in the database in order to perform the update in both tables atomically, before the referential integrity constraint is enforced.