0
我以前org.hibernate.Session.getNamedQuery
獲得從XML文件中的以下查詢:getNamedQuery不檢索數據
<sql-query name="filterTraineesBySection"><![CDATA[
select usr.USERNAME, crs.NAME
from TBLCOURSEROLE crsr
inner join TBLCOURSE crs on crs.ID=:courseId and crsr.ROLEID=3
inner join USER_ usr on crsr.USERID=usr.ID
]]>
</sql-query>
我用上面的方法如下:
public ArrayList<String[]> getTraineesBySectionId(String sectionId) {
String[] traineeDetails = null;
ArrayList<String[]> traineesList = new ArrayList<String[]>();
Query SgTrainees = null;
SgTrainees = this.getSession().getNamedQuery("filterTraineesBySection");
SgTrainees.setString("courseId", sectionId);
Iterator trainees = SgTrainees.list().iterator();
while (trainees.hasNext()) {
Object[] tuple = (Object[]) trainees.next();
traineeDetails = new String[2];
traineeDetails[0] = (String) tuple[0];
traineeDetails[1] = (String) tuple[1];
traineesList.add(traineeDetails);;
}
return traineesList;
}
的問題是,上面的查詢執行成功地在DBMS中檢索108行,而在java中它不會返回任何東西!
我想這樣做,但什麼都沒有改變! –
我猜他們是在你的查詢中的一些問題。你可以分享日誌嗎? – BDR
是的,請分享您的日誌爲@BalajiReddy說。 – Yubaraj