1
我有兩個實體Issue和Issue_Tracker
。我已經以一對多的方式加入了這張桌子。在Issue_Tracker
,我們可以有一個像使用休眠獲取更新的行在一對多映射
issue_id tracker_status tracked_time
123 Assigned 1/8/2013 11:44
123 Assigned 1/8/2013 11:45
123 Completed 1/8/2013 11:52
32 Assigned 1/9/2013 16:46
33 Assigned 1/9/2013 16:47
33 Cancel 1/9/2013 16:49
多個條目我要訂購由tracked_time的Issue_tracker實體,所以我可以tracker_status
。我現在用的標準得到的數據只有最後一次更新,但我得到的第一個條目例如:對於issue_id 123,我將tracker_status設爲Assigned,但我想爲id 123獲取tracker_status : Completed
。如何實現此目的。吾道如下
Criteria criteria = session.createCriteria(Issue.class);
criteria.setFirstResult(from);
criteria.setMaxResults(size);
criteria.setFetchMode("Issue.issueTracker",FetchMode.JOIN);
criteria.add(Restrictions.eq("status", "Escalate To"));
return criteria.list();
Issue.java
public class Issue implements Serializable
{
private Integer issue_id;
private String issue_description;
private Date issue_raised_date;
private Set<Issue_Tracker> issueTracker = new HashSet<Issue_Tracker>(0);
@OneToMany(fetch=FetchType.LAZY, mappedBy="issue_id")
public Set<Issue_Tracker> getIssueTracker() {
return issueTracker;
}
public void setIssueTracker(Set<Issue_Tracker> issueTracker) {
this.issueTracker = issueTracker;
Issue_Tracker.java
public class Issue_Tracker implements Serializable
{
private Integer issue_id;
private String tracker_status;
private Timestamp tracked_time;
我希望你們能得到什麼,我想問問,任何幫幫我?
感謝,但沒有工作收到此錯誤拋出java.lang.ClassNotFoundException:antlr.TokenStream –
從應用程序庫缺少一個JAR文件:HTTP:/ /www.findjar.com/class/antlr/TokenStream.html –
好吧,我會把這個罐子添加到我的課程路徑 –