我有两个模型,分别称为对帐和装运。我定义了它们之间的单向多体关系船(因为不想在对帐时紧密耦合运输),并将其命名为ReconShipmentMapped(不是模型)。现在,对帐(R1)已映射到多个货件(S1,S2,S3,S4,S5)。我能够设置此关系,并且在ReconShipmentMapped表(不是模型)中找到了映射对帐R1的5个条目。现在,我要从中删除S3映射。当我获取映射的货件并从中删除S3并将其再次保留时,它在表中创建了9个条目,我希望ReconShipmentMapped表中应仅保留4个结果条目。
我在下面提到模型结构,请帮帮我:
运输模型
@SuppressWarnings("serial")
@Entity
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@JsonIgnoreProperties(value = "requestToken")
public class Shipment {
@Column(nullable = false, unique = true)
private String barCode;
@Column(nullable = false, unique = true)
@JsonIgnore
private String referenceId;
@Column
private String droppedBy;
@Column
private String collectedBy;
//getter setter methods
}
对帐模型
@SuppressWarnings("serial")
@Entity
public class Reconciliation
@Column
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "ReconShipmentMapped", joinColumns = {
@JoinColumn(name = "payment_recon_id") }, inverseJoinColumns = {
@JoinColumn(name = "shipment_id") })
private Set<Shipment> shipment = new HashSet<Shipment>();