我有一个简单的问题。我有User
和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;
}
问题是,当我想删除对象User
时,由于com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: **Cannot delete or update a parent row: a foreign key constraint fails**
,它不允许我这样做。如何设置在删除Log
时删除所有User
个对象的行为?