下面是函数和查询错误HQL查询像
public List<T> searchWordRecords(String parameter, String paramValue, Long statusID) throws AmmachiServerException
{
Session session = null;
List<T> recordList = null;
try
{
session = HibernateUtils.getHibernateConnection();
String hqlQueryString = "Select p from " + theClass.getSimpleName() + " p where " + parameter +" like '% :paramValue%'and StatusID = :statusID";
Query hqlQuery = session.createQuery(hqlQueryString);
hqlQuery.setParameter("paramValue", paramValue);
hqlQuery.setParameter("statusID", statusID);
recordList = hqlQuery.list();
}
catch(HibernateException he)
{
processException(he);
}
finally
{
HibernateUtils.closeConnection(session);
}
return recordList;
}
我得到了错误org.hibernate.QueryParameterException:无法找到名为参数[paramValue]
能否请你帮助别人解决这
字符串hqlQueryString = “select p from”+ theClass.getSimpleName()+“p where”+ parameter +“=:paramValue and StatusID =:statusID”; hqlQuery.setParameter(“paramValue”,“%”+ paramValue +“%”);这是好的 – VSN
你仍然需要匹配,所以继续使用''''而不是'=' – kostja