我是hibernate的新手,试图在hibernate中运行查询,但是我遇到了一个例外
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.
hbm.xml.
请参考这个。
hbm.xml文件中没有定义的关联