DB db = DBFactory.getInstance();
DBQuery dbq = db.createQuery(query);
dbq.setEntity("identId", identity);
dbq.setString("name", groupName);
dbq.setEntity("context", bgContext);
List res = dbq.list();
if (res.size() == 0) return null;
else if (res.size() > 1) throw new AssertException("more than one result row found for (identity, groupname, context) ("
+ identity.getName() + ", " + groupName + ", " + bgContext.getName());
return (BusinessGroup) res.get(0);
}