收到意外标记的错误:ON 靠近第 1 行第 135 列

2023-12-31

我是休眠新手,并尝试在休眠中运行查询,但我收到以下异常

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;

我做错了什么?

Thanks


SQL 中的许多构造无法一对一地迁移到 HQL。在 HQL 关键字中WITH被用来代替ON,当加入特定条件时。此构造特定于 Hibernate,预计不能与其他 JPA 提供程序一起使用。

关于 HQL 的章节 http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/queryhql.html尤其是16.3 关联和连接 http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/queryhql.html#queryhql-joinsHibernate Core Reference Manual 中的内容值得一读。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

收到意外标记的错误:ON 靠近第 1 行第 135 列 的相关文章

随机推荐