我有两个实体 -
@Entity
public class PriceList extends Model {
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(
joinColumns = {@JoinColumn(name = "price_list_id")},
inverseJoinColumns = {@JoinColumn(name = "price_list_item_id")},
uniqueConstraints = {@UniqueConstraint(columnNames = {"price_list_id", "price_list_item_id"})}
)
private Set<PriceListItem> priceListItems = new HashSet<>();
}
@Entity
public class PriceListItem extends Model {
@ManyToOne(optional = false)
private Task task;
private double price;
}
当我尝试向列表中添加新的PriceListItem
时(价格表已经保留),并尝试更新,我得到以下错误 -
引起:java.sql.SQLIntegrityConstraintViolationException:无法删除或更新父行:外键约束失败(
track
。price_list_item
,CONSTRAINTFK19qdwn6vfsjxdxl7355ojo39l
FOREIGN KEY({{1参考文献task_id
(task
))
我用来更新的代码是 -
id
任何人都知道我收到此错误的原因?我正在使用最新的Hibernate和最新的Spring Data JPA。