我有四个实体参与了我遇到一些麻烦的查询。关系如下:Exchange----*Contract*----*Combo----*Trade
和(简化)实体如下:
@Entity
public class Exchange implements Serializable {
@Id(name="EXCHANGE_ID")
private long exchangeId;
@Column
private String exchangeShortName;
}
@Entity
public class Contract implements Serializable {
@Id
private long contractId;
@Column
private String contractName;
@ManyToOne
@JoinColumn(name="EXCHANGE_ID")
private Exchange exchange;
@ManyToMany
@JoinTable(name="CONTRACT_COMBO",
joinColumns = { @JoinColumn(name="CONTRACT_ID") },
inverseJoinColumns = {@JoinColumn(name="COMBO_ID")})
private Set<Combo> combos;
@Column(name = "ACTIVE_FLAG")
private String activeFlag;
}
@Entity
public class Combo implements Serializable {
@Id
@Column(name="COMBO_ID")
private Integer id;
@ManyToMany
@JoinTable(name="CONTRACT_COMBO",
joinColumns = { @JoinColumn(name="COMBO_ID") },
inverseJoinColumns = {@JoinColumn(name="CONTRACT_ID")})
private Set<Contract> legs;
@OneToMany(mappedBy = "combo")
private Set<Trade> trades;
}
@Entity
public class Trade implements Serializable {
@Id
@Column(name="TRADE_ID")
private long tradeId;
@Column(name="REFERENCE")
private String reference;
@ManyToOne
@JoinColumn(name="COMBO_ID")
private Combo combo;
}
我想获得一个我无法完成的特定交易所的所有交易清单MEMBER OF
。任何帮助,将不胜感激。