cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Владимир Сухинин <suhininvladi...@gmail.com>
Subject Re: Queries with joins and entity qualifiers are broken in cayenne-3.1.2
Date Tue, 12 Dec 2017 11:37:03 GMT
I've found that if I use ExpressionFactory.matchDbExp for
DbEntity.setQualifier,
cayenne use wrong aliases when building join queries.
And if I use ExpressionFactory.matchExp for DbEntity.setQualifier, cayenne
build joins with correct aliases.
Using matchExp  instead of matchDbExp  for DbEntity looks wired, but it
works. So I've found a workaround, but not sure, is it a bug or a feature.

2017-12-11 17:31 GMT+03:00 Владимир Сухинин <suhininvladimir@gmail.com>:

> We have a database where all entities have a qualifier for "deleted"
> field, which is added via DbEntity.setQualifier(Expression) during
> DataMap loading.
> When we create a SelectQuery, this qualifiers added in join "ON" node with
> wrong table alias.
> So our query looks like this:
> SELECT DISTINCT t0.CUSTOMERID AS c0,
>       UPPER(t0.CUSTOMERLASTNAME)   AS c1
>     FROM CUSTOMER t0
>     LEFT JOIN CUSTOMER_GROUP t1
>     ON (t0.CUSTOMERID = t1.CUSTOMERID
>     AND t0.DELETED    = 0)
>     JOIN GROUP t2
>     ON (t1.GROUPID = t2.GROUPID
>     AND t0.DELETED = 0)
>     WHERE (t2.GROUPTYPEID = 101100100145)
>     AND (t0.DELETED       = 0)
>     ORDER BY UPPER(t0.CUSTOMERLASTNAME)
>    ;
> Earlier we've used cayenne-3.0RC3, and there queries with same DataMap and
> qualifiers creates correctly
> SELECT DISTINCT t0.CUSTOMERID,
>       UPPER(t0.CUSTOMERLASTNAME)
>     FROM CUSTOMER t0
>     LEFT JOIN CUSTOMER_GROUP t1
>     ON (t0.CUSTOMERID = t1.CUSTOMERID
>     AND t1.DELETED    = 0)
>     JOIN GROUP t2
>     ON (t1.GROUPID = t2.GROUPID
>     AND t2.DELETED = 0)
>     WHERE (t2.GROUPTYPEID = 101100100145)
>     AND (t0.DELETED       = 0)
>     ORDER BY UPPER(t0.CUSTOMERLASTNAME)
> ;
>
> --
> Vladimir Suhinin
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message