cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Atli Páll Hafsteinsson <atlip...@gmail.com>
Subject Re: Type safe queries & more
Date Fri, 16 Sep 2011 13:27:48 GMT
We did notice the ExpressionFactory and actually use it to generate
the expressions :)

This is indeed an interesting discussion, especially for cayenne noobs like me.

Atli Páll Hafsteinsson
atlipall@gmail.com



On Fri, Sep 16, 2011 at 1:22 PM, Michael Gentry <mgentry@masslight.net> wrote:
> Hi Atli,
>
> Using ExpressionFactory, you can avoid a lot of the text-based queries
> by using the constants generated by Cayenne Modeler in the superclass.
>  Something like:
>
> Expression exp = ExpressionFactory.matchExp(User.USERNAME_PROPERTY, username);
>
> In 3.1, a static makePath() method has been added to CayenneDataObject
> to make it easier to use the constants with relationships:
>
> Expression exp =
> ExpressionFactory.matchExp(makePath(User.ROLE_PROPERTY,
> Role.NAME_PROPERTY), Role.ADMIN);
>
> makePath() joins the strings you pass it with a "." so you end up with
> something like "role.name", but it is using Java constants so you
> can't introduce typos.
>
> I'm not trying to distract from the current (and interesting)
> conversation, just pointing out ExpressionFactory if you missed it.
>
> Thanks,
>
> mrg
>
>
> 2011/9/16 Atli Páll Hafsteinsson <atlipall@gmail.com>:
>> For me a big part of the reason for implementing this is to get rid of
>> text based queries as they cannot be verified and therefore error
>> prone. Plus you have to know more about the data structure.
>

Mime
View raw message