我是hibernate和JPA的新手,我正在尝试做下一件事:
public class Centre extends JpaStandardVersionableEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "sq")
@SequenceGenerator(name = "sq", sequenceName = SQ_NAME)
@Column(name = "ID_CTR", nullable = false)
private Integer idCtr;
...
@JoinColumn(name = "ID_DRC", referencedColumnName = "ID_DRC", nullable = false)
@ManyToOne(cascade = CascadeType.ALL, optional = false, fetch = FetchType.LAZY)
private Address idDrc;
}
public class Address extends JpaStandardVersionableEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "sq")
@SequenceGenerator(name = "sq", sequenceName = SQ_NAME)
@Column(name = "ID_DRC", nullable = false)
private Integer idDrc;
}
使用级联 ALL 以便在我注册中心时插入地址。
但是我遇到了这个错误:违反完整性约束 FK_CTR_DRC - 找不到父键
似乎这没有按预期工作......有什么想法吗?提前致谢