Hi Lachlan,
Coincidentally I finished some documentation on this feature over the
weekend:
http://cayenne.apache.org/doc/path-expressions.html ("Aliases in Path
Expressions")
http://cayenne.apache.org/doc/expression-factory-utilities.html
("Split Expressions with matchAllExp()")
Essentially the pipe symbol can only be used with 'matchAllExp'. This
is a special case, and I am not sure it makes sense in a general case.
General case is handled a bit differently via "path aliases". I.e. for
each group of paths that you want to be executed as a single join, you
create a single alias. Different aliases over matching paths generate
separate joins.
Also aliases would only work with 3.0RC2 (aka 3.0-STABLE branch), as
it contains a fix for CAY-1361. matchAllExp() with pipes works in RC1.
Andrus
On Jan 13, 2010, at 6:13 AM, Lachlan Deck wrote:
> Hi there (particularly Andrus),
>
> I notice in CAY-514[1] that there's a split syntax using the pipe
> symbol that works for matchAll expressions. Is this the only
> possible way of achieving split expressions?
>
> If we have two expressions (initialised separately - but combined
> for the select) that happen to be testing the same keyPath across a
> toMany is it possible to enforce similar behaviour somehow?
>
> e.g.,
> Expression e1 = ExpressionFactory.like("cousins.firstName", "fred");
> Expression e2 = ExpressionFactory.like("cousins.firstName", "joe");
> Expression e = e1.andExp(e2);
>
> The resulting sql removes duplicate joins and thus produces no
> results.
>
> Trying with pipes fails to resolve the paths:
> Expression e1 = ExpressionFactory.like("cousins.|firstName", "fred");
> Expression e2 = ExpressionFactory.like("cousins.|firstName", "joe");
> // throws exceptions at runtime
>
> So is it possible to make this work other than using matchAll?
>
> [1] http://issues.apache.org/jira/browse/CAY-514
>
> with regards,
> --
>
> Lachlan Deck
>
>
This archive was generated by hypermail 2.0.0 : Wed Jan 13 2010 - 02:54:38 EST