I have a simple question. I have User
and Log
.
@Entity
public class User {
@Column
private String login;
@Column
private String password;
}
@Entity
public class Log {
@Column
private int type;
@ManyToOne()
@JoinColumn(name="user")
private User user;
}
Problem is, when I want to remove object User
, it wont allow me to do it because of com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: **Cannot delete or update a parent row: a foreign key constraint fails**
. How to set behaviour to delete all Log
objects when removing User
?