yes, you're quite right ... it's a "problem" how you're trying to query the many-to-one ...
Code:
criteria.add(Expression.eq("homeOrgUnit", new Long(orgUnitId)));
is not possible because Hibernate would expect an instance of "uk.gov.ch.chips.common.user.OrgUnit" and not the id ... If you want to use the id in the query, there're several possibilities.
Look at the reference-doc (or HiA) for using an "Alias" or "join" in combination with criteria ...
You can try something like this (not tested - just an example):
Code:
Criteria criteria = getSession().createCriteria(User.class);
criteria.add(Expression.lt("effectiveDate", DateUtils.today()));
criteria.add(Expression.gt("endDate", DateUtils.today()));
criteria.createAlias("homeOrgUnit", "ho");
criteria.add(Expression.eq("ho.nameOfTheIDProperty", new Long(orgUnitId)));
...
HiH
curio