我一整天都有一个问题,最后我别无选择。首先,我必须澄清我仍然是一名初级开发人员,因此我希望我的代码中有一些奇怪的东西:P
我正在尝试合并通过REST接收的新对象,到目前为止没有问题,发送对象,REST方法运行,但是当到达合并点时,我收到此错误:
java.sql.SQLIntegrityConstraintViolationException: ORA-02291: Integritäts-Constraint (KEYPROFILE_DEV.FK_PERSON_KEYPROFILE_USER) verletzt - übergeordneter Schlüssel nicht gefunden
含义“未找到父键”。我已检查过其他帖子,问题在于数据库中的触发器,但我的表没有任何触发器(用
检查)select * from all_triggers
where table_name = 'KEYPROFILE_USER'
此查询)。
所以我想尝试将entityManager.merge(keyProfileUser)
新KeyProfileUser
与这些成员合并:
/** Represents the primary key. */
@Id
@Column
@SequenceGenerator(name = "keyProfileUserIdSequenceGenerator",
allocationSize = 1, sequenceName = "KEYPROFILE_USER_ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "keyProfileUserIdSequenceGenerator")
private Integer id;
/** Represents login attribute. */
@Column
private String login;
/** Represents password attribute. */
@Column
private String password;
/** Represents password attribute. */
@Column
@Enumerated(EnumType.STRING)
private UserRole userRole;
/** Represents the attribute. */
@OneToOne(cascade = { CascadeType.MERGE, CascadeType.REMOVE,
CascadeType.PERSIST }, fetch = FetchType.EAGER)
@JoinColumn(name = "PERSON_ID", nullable = true)
private Person person;
这是类Person,它有更多的字段,但最重要的是我认为它是主键:
/** Represents the primary key. */
@Id
@Column
@SequenceGenerator(name = "personalIdSequenceGenerator", allocationSize = 1,
sequenceName = "PERSON_ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "personalIdSequenceGenerator")
private Integer id;
这基本上就是问题所在。欢迎任何帮助。
谢谢!