Re: Question about key path expression

From: Michael Gentry (mgentr..asslight.net)
Date: Tue Sep 08 2009 - 11:38:03 EDT

  • Next message: Reinout van Schouwen: "Re: Question about key path expression"

    Also, what is the name of your relationship from Person to PersName?

    On Tue, Sep 8, 2009 at 11:19 AM, Reinout van Schouwen<reinou..mail.com> wrote:
    > 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
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Sep 08 2009 - 11:38:39 EDT