I have two tables:
entities:
- id
- someValues
and other table, with foregin key on id field
connectedEntities:
- entityId (foregin)
- otherObjectId (foregin)
I need to delete entity by id, but when I tried to delete just from entities
table, there's FK violation.
Also, I want to use @SqlUpdate or other annotation from JDBI framework.
Does anybody know how to do something like this?
Thanks to @G_H , I found what I was looking for.
I just needed to add ON DELETE CASCADE
to my foregin key definition, and everything worked just fine.
Here's the tutorial - mysqltutorial.org/mysql-on-delete-cascade