Skip to content
Advertisement

How to cascade delete set of enums in JPA?

I have the roles field in User entity:

JavaScript

when I try to delete user with a query, the referential integrity constraint violation occurs, because user is referenced from User_roles table.

How to solve this in any way?


DDL for related table shows

JavaScript

i.e. it doesn’t contain ON DELETE CASCADE clause. I need it be there.

Advertisement

Answer

You can add ON DELETE CASCADE clause to the FOREIGN KEY constraint in the following way:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement