So i have a MyUser entity which refers to a Role entity with a many to many relationship. But when i try to delete the user, i always get the errror that the user_id is always referenced on the user_role jointable...
I have already tried every cascade type... but didn't get the solution Please help Thanks
@Table(name = "users") public class MyUser { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; ... Other properties ... @ManyToMany @JoinTable( name = "users_roles", joinColumns = @JoinColumn( name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn( name = "role_id", referencedColumnName = "id")) private Collection<Role> roles; // getters setters } @Entity @Table(name = "roles") public class Role { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; private String role; // getters setters }