我已经像这样暂停了JPA实体:
@Entity
@Table(name = "[pembelian].[PO]")
public class PO implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private Date tglPO;
private String keterangan;
private String alamat;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "po", orphanRemoval = true)
private List<DetailPO> detailPOList;
}
第二个是
@Entity
@Table(name = "[pembelian].[DetailPO]")
public class DetailPO implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@ManyToOne
@JoinColumn(name = "PO_id")
private PO po;
private double qty;
private BigDecimal harga = new BigDecimal(0);
private BigDecimal diskon = new BigDecimal(0);
private BigDecimal pajak = new BigDecimal(0);
}
就我而言,我有一个包含3个列表节点DetailPO的PO。然后,我删除了一个DetailPO节点,所以我现在只有2个列表节点。之后我想将PO保存在数据库中。数据已成功保存,但我删除的DetailPO未在数据库中删除。
我的代码有错误吗?
谢谢你。