【发布时间】:2016-09-11 00:23:04
【问题描述】:
jpa 类是这样的:
public class JpaAlertConfiguration{
...
@OneToOne(fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name = "alert_type_id", nullable = false, referencedColumnName = "id", insertable = false, updatable = false)
private JpaAlertType alertType;
}
从这个类方法调用创建实体。
@Override
@Transactional
public JpaAlertConfiguration createEntity(JpaAlertConfiguration entity) throws Exception
{
getAuthorizer().checkCreate(ENTITY_NAME);
validateFields(entity);
getAuthorizer().checkAccountAccess(entity.getAccount().getId(), null);
entity = attachAssociatedEntities(entity);
// entity.setStatusColumns(new StatusColumns().setStatus(ResourceStatus.Disabled));
entity = super.createEntity(entity);
entity = transformResult(entity);
return entity;
}
我确保在调用此行之前,entity = super.createEntity(entity); 填充了 JpaAlertType id 值,它只是 alertConfig 表的“alert_type_id”。
我遇到了异常:
原因:org.postgresql.util.PSQLException:错误:“alert_type_id”列中的空值违反非空约束 详细信息:失败行包含 (3, Speed Alert, Speeding Alert, 5, t, null, Enabled, 0, 2016-09-06 17:56:30.556+05:30, 2016-09-06 17:56:30.58+ 05:30, 2016-09-06 17:56:30.556+05:30, null, f, f)。
请推荐
【问题讨论】:
-
JpaAlertType是什么,entity.alertType的 vakue 是什么?
标签: java postgresql hibernate jpa