我是休眠的新手,试图在休眠中运行查询,但是我遇到了一个例外
unexpected token: ON near line 1, column 135 [SELECT A.comp_id.appRefNo ....
这是代码
StringBuffer query = new StringBuffer("SELECT A.comp_id.appRefNo,
A.comp_id.custId from ");
query.append(LosaCustContactZ.class.getName());
query.append(" A INNER JOIN " + LosaCust.class.getName() + " B
ON ( B.comp_id.appRefNo = A.comp_id.appRefNo AND " +
"B.comp_id.custId = A.comp_id.custId) INNER JOIN " + LosaApp.class.getName() + " C
ON " + "(B.comp_id.appRefNo = A.comp_id.appRefNo) ");
query.append("WHERE C.comp_id.appRefNo != ?" + " AND C.appDt >= ? AND
A.contactT = 'PHONE'" );
if (StringUtils.isNotEmpty(phoneNums)) {
query.append(" AND A.contact IN(" + phoneNums + ")");
}
List<LosaCustContactZ> resultList = null;
try {
resultList = getHibernateTemplate().find(query.toString(),
new Object[] { appRefNo, appDate });
} catch (Exception e) {
String message = e.getMessage();
System.out.println();
}
return resultList;
我做错了什么?
谢谢
最佳答案
似乎您的hbm.xml.
中缺少映射关联
请参考这个。
No defined association in hbm.xml file