Hi, 

I have a table Person and a table PersName. I've created a relation
between PersName and Person so that each PersName links to a Person. In
other words, a Person may have multiple PersNames.

Is it possible to do a query like this:

// find all Persons whose family name starts with A
 final Expression queryTemplate = Expression.fromString("persname.familyName 
like '$name%'");
 Map<String,String> queryParams = Maps.newHashMapWithExpectedSize(1);
 queryParams.put("name", "A"); // TODO "A" from parameter
 Expression qualifier = queryTemplate.expWithParameters(queryParams);
 SelectQuery query = new SelectQuery(Person.class, qualifier);
 query.addOrdering("familyName", true);

When I try this, I get:
org.apache.cayenne.exp.ExpressionException: [v.2.0.4 October 12 2007] Can't 
resolve path component: [Person.persname].

It is true that the table Person has no field 'persname' but if I read
http://cayenne.apache.org/doc20/building-expressions.html correctly,
Cayenne should automatically determine all the join information.

How should I build the key path expression?

regards,

-- 
Reinout van Schouwen

Reply via email to