这是我的HQL查询:
buffer = new StringBuilder();
buffer.append("SELECT R ");
buffer.append("FROM " + getEntityClassName() + " R ");
buffer.append("LEFT JOIN E.debit D ");
buffer.append("LEFT JOIN E.etablissement E ");
buffer.append("WHERE D.id = :idDebit ");
buffer.append("ORDER BY R.periodeDebut DESC ");
hqlQuery = session.createQuery(buffer.toString());
hqlQuery.setInteger("idDebit", idDebit);
我收到了这个错误:
java.lang.IllegalArgumentException: Parameter idDebit does not exist as a named parameter in [SELECT R FROM fr.gouv.finances.douane.gimt.dao.base.commun.impl.DebitReventeDaoImpl R LEFT JOIN E.debit D LEFT JOIN E.etablissement E WHERE D.id = :idDebit ORDER BY R.periodeDebut DESC ]
当我按setParameter("idDebit", idDebit)
更改 setInteger 时,出现此错误:
org.hibernate.QueryParameterException: could not locate named parameter [idDebit]
如果我改变它也是这样的:
WHERE D.id = ?
setParameter(0, idDebit)
我收到了这个错误:
org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1
感谢您的帮助
答案 0 :(得分:0)
setParameter(0, idDebit)
更改为
setParameter(1, idDebit)