0
,休眠拋出異常:休眠拋出不能刪除或嘗試從數據庫中刪除的項目更新父行例外
Cannot delete or update a parent row: a foreign key constraint fails (`ticketer`.`UserOrder_Ticket`, CONSTRAINT `FKiyeesx6teiqckayn6agqw5b58` FOREIGN KEY (`tickets_id`) REFERENCES `Ticket` (`id`))
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
我的實體:
票:
@Entity
public class Ticket {
@Id
@GeneratedValue
private Long id;
@OneToOne(cascade = CascadeType.ALL)
private Event event;
private String number;
private BigDecimal price;
}
UserOrder:
@Entity
public class UserOrder {
@Id
@GeneratedValue
private Long id;
@OneToMany(cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.FALSE)
private List<Ticket> tickets;
@OneToOne
private User user;
private BigDecimal price;
private PaymentStatus paymentStatus;
private LocalDateTime orderDate;
}
我的數據庫有連接實體(休眠標準)的表格。 是否有任何可能的解決方案使其工作?我正在使用MySql。
什麼是ticketer? – Sam
應用程序和數據庫的名稱 – egzaell
我想你正試圖更新在其他表中引用爲外鍵的主鍵值。 – Nidhi257