我有3個實體通過onetoone關係連接。我的目標是獲得使用休眠條件的實體,其中match.status != null
。並且如何告訴hibernate不要加入algo
實體導致,應該是(pick.algo = null)。如何在休眠條件中使用連接列?
@Entity
public class Pick {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int pid;
@Column(columnDefinition="DATETIME")
private Date insertTime;
@Column(columnDefinition="DATETIME")
private Date setupResTime;
@OneToOne
private DbMatch match;
@OneToOne
private Algo algo;
@Transient
private Integer algoID;
....
條件查詢:
public List<Pick> getPicksHistory(){
Criteria criteria = session.createCriteria(Pick.class);
criteria.add(Restrictions.isNotNull("match.status"));
return criteria.list();
}