我得到一个 JUnit 测试的参照完整性约束违规。使用playframework和我的两个实体如下。
@Entity
public class User extends Model{
public String email;
public String password;
@OneToOne(mappedBy="user",cascade=CascadeType.ALL)
public Patent patent;
}
@Entity
public class Patent extends Model{
@OneToOne
public User user;
}
在我的 Junit 测试中,以下行失败
User.findById(user.id)._delete();
Referential integrity constraint violation: "FK340C82E547140EFE: PUBLIC.PATENT FOREIGN KEY(USER_ID) REFERENCES PUBLIC.USER(ID)"; SQL statement:
delete from User where id=? [23003-149]
谢谢