在使用springboot和springjpa的项目中,我有两个实体functionconfiguration和invokefunctionresult。
@Entity
@Table(name = "function_configuration")
public class FunctionConfigurationEntity {
@Id
@Column(name = "id_function_configuration")
@GeneratedValue(strategy = IDENTITY)
private Integer idFunctionConfiguration;
}
@Entity
@Table(name = "invoked_function_result")
public class InvokedFunctionResultEntity {
@Id
@Column(name = "id_invoked_result_function")
@GeneratedValue(strategy = IDENTITY)
private Integer idInvokedResultFunction;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "function_configuration_id", nullable = false, foreignKey = @ForeignKey(name = "function_configuration_fk"), referencedColumnName = "id_function_configuration")
private FunctionConfigurationEntity functionConfiguration;
}
invokefunctionresult的外键是functionconfiguration的id。如果我尝试使用invokefunctionresult中存在的functionconfiguration的id执行删除:
@Transactional
@Modifying
@Query(value = "DELETE FROM FunctionConfigurationEntity fce WHERE fce.idFunctionConfiguration = idFunctionConfiguration")
void deleteByFunctionConfigurationId(@Param("idFunctionConfiguration") Integer functionConfigurationId);
我得到以下错误:原因:org.postgresql.util.psqlexception:错误:表“function\u configuration”上的update或delete语句违反了表“invoked\u function\u result”上的外键约束“function\u configuration\u fk”
我该怎么修?
暂无答案!
目前还没有任何答案,快来回答吧!