Tuesday, May 5, 2009

Hql with collections and named parameters

An example of how you can use hql to query collections and names parameters. The bold part is for collections. The find() method is from Spring HibernateTemplate.

String query = "select cp from CaseProduct cp, LcLabelChange lc "
+ " where cp.puid=? "
+ " and lc member of cp.labelChanges "
+ " and lc.lcMitigation.caseIngredient.caseIngredientSeq=?";
Object[] params = new Object[]{puid, caseIngredientId};
List list = find(query, params);

No comments:

Post a Comment