I have the following table structure:
table A --------- id | name table B -------------- id | x | y | z table B (id) : references table A (id)
I can modify name of table A even if data present at table B for id of table A ,
as it is not a foreign key.
Now I want to restrict the modification of name variable of table A, if id of table A has records in other table.
Do I need to query each table where id of table A is used as foreign key, or there is any other option in Hibernate or MySQL.
You can do that right in the database via a constraint on the key the foreign key refers to. The database will then take the action you specify automatically.