我有三个实体名为SUBJ(高级),SUBJ_DOC(超级)和DOC(儿童),我想为子表列应用orderby注释。当我通过下面的代码应用时(order by子句没有出现在hibernate生成的select查询中)。
请帮我用子实体表cloumn获取结果。
@Entity
@Table(name = "SUBJ")
@Where(clause = "ROW_INAC_INDC = 0")
public class Subj implements java.io.Serializable {
private Set<SubjDoc> subjDocs = new HashSet<SubjDoc>(0);
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "SUBJ_ID")
@Where(clause = "ROW_INAC_INDC = 0")
public Set<SubjDoc> getSubjDocs() {
return subjDocs;
}
public void setSubjDocs(Set<SubjDoc> subjDocs) {
this.subjDocs = subjDocs;
}
}
@Entity
@Table(name = "SUBJ_DOC")
@Where(clause = "ROW_INAC_INDC = 0")
public class SubjDoc implements Serializable {
private static final long serialVersionUID = 1L;
private Long subjDocId;
private Doc doc;
@OneToOne(fetch = FetchType.EAGER, orphanRemoval = true)
@JoinColumn(name = "DOC_ID", nullable = false)
@OrderBy(clause="ORDER_ID DESC")
public Doc getDoc() {
return doc;
}
public void setDoc(Doc doc) {
this.doc = doc;
}
}
@Entity
@Table(name = "DOC")
public class Doc implements java.io.Serializable {
private Integer orderID;
@Column(name = "ORDER_ID", precision = 7, scale = 0)
public Integer getOrderID() {
return orderID;
}
public void setOrderID(Integer orderID) {
this.orderID = orderID;
}
}