Hi everyone,
I’ve got a weird little error when using a Criteria query.
The function is used to find a Person by their User.id (ie, Person one-to-one User)
The function is in PersonService and is:
public any function getPersonByUserID(required numeric userID)
{
c = newCriteria();
c.createAlias(‘user’,‘user’);
c.and(c.restrictions.eq(‘id’,javacast(“int”,arguments.userID)));
return c.count();
}
In that guise it works fine, and produces a count of 1 for my test.
The error appears when I change .count() to .get() OR .list()
The Error is:
Detail The coldbox main controller has not been initialized ErrorCode [empty string] ExtendedInfo [empty string] Message ColdBox Controller Not Found
My hibernate logging tells me the query is run perfectly, and returns exactly what I expect.
It is called via a test:
function testgetPersonByUserID()
{
result = model.getPersonByUserID(2);
debug(result);
}
Any thoughts on what the problem is?
Cheers
Steve