When I run the method: dao.query("SELECT p FROM Profile p WHERE p.group = :id ORDER BY p.datestamp :key", map);
I get the following error:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: : near line 1, column 93 [SELECT p FROM Profile p WHERE p.group = :id ORDER BY p.datestamp :key]
Following is the query method implemenation; anyone see what is wrong?
public List<?> query(String criteria, HashMap<String, ?> args) {
Query sqlQuery = this.em.createQuery(criteria);
Set<String> keys = args.keySet();
Iterator<String> iter = keys.iterator();
while (iter.hasNext()) {
String key = iter.next();
sqlQuery.setParameter(key, args.get(key));
}
return sqlQuery.getResultList();
}
DESC
orASC
depending on the:key
parameter. – AMS12