A级
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "A")
private Set<B> Bs = new HashSet<B>();
B类
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumns({
@JoinColumn(name = "INT_C", nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "SBC_C", nullable = false, insertable = false, updatable = false) })
private A a;
当我这样做时,getB()
我只会得到一行,而对于 and 的组合INT_C
,SBC_C
则存在 3 行。
请让我知道这里有什么问题。
Rows in DB
SBC_C INT_C FILE_C OUTPUT_FILE_NM
--------------------------------------------
MYACCESS CR CRC DataHub_DEVC.dat
MYACCESS CR CRG DataHub_DEVG.dat
MYACCESS CR CRU DataHub_DEVU.dat
B 实体 ID:
@EmbeddedId
private ObFileId id;
ObFileId 类:
@Embeddable
public class ObFileId implements IXDomain {
@Override
public int hashCode() {
return getICode().hashCode() + getSCode().hashCode();
}
@Override
public boolean equals(Object obj) {
return ((obj instanceof ObFileId)
&& (getICode().equals(((ObFileId) obj)
.getICode())) && (getSubscriberCode()
.equals(((ObFileId) obj).getSCode())));
}