Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 49873200D56 for ; Tue, 12 Dec 2017 13:04:26 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 47E0F160C0F; Tue, 12 Dec 2017 12:04:26 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8D899160BE7 for ; Tue, 12 Dec 2017 13:04:25 +0100 (CET) Received: (qmail 35052 invoked by uid 500); 12 Dec 2017 12:04:24 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 35039 invoked by uid 99); 12 Dec 2017 12:04:24 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Dec 2017 12:04:24 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id D52421A0E4C for ; Tue, 12 Dec 2017 12:04:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.301 X-Spam-Level: X-Spam-Status: No, score=-0.301 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, KAM_NUMSUBJECT=0.5, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=objectstyle.org header.b=JTzpWZoY; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=ELacro19 Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id S0H6veLVLivj for ; Tue, 12 Dec 2017 12:04:22 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 537D95F367 for ; Tue, 12 Dec 2017 12:04:22 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id E813120A5F for ; Tue, 12 Dec 2017 07:04:21 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Tue, 12 Dec 2017 07:04:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=objectstyle.org; h=content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=tq+aH3TPFbur4ZCvL1KXq6sYeE GsQvpTaLTZdos9TCA=; b=JTzpWZoYsK85TU7Z6ZiX2MdtHTZTyQXUKpXoAh7b9p 7ba417wWJXThi83GyeB3neU0ksoRC0w2Eu93q+3J9/+MTf1Zzo702dEm72gLZ1y9 3btWDV9MNpzLaY6eCNFD1PyS31zyPVI8+CnyvfXcYyAXcN6zhPX4pxVspfbFUA9g Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=tq+aH3 TPFbur4ZCvL1KXq6sYeEGsQvpTaLTZdos9TCA=; b=ELacro19/Amq2iqORQ0LNk eWgVEhjPxOVm3ghXGghcPMoLwuPOUVkHVQ+XgAPIfsLCA3DsOFp66XSZgPA13AML 5Ks2SFvRsGBGfWurnXhOpxT7M3y/ZWDXeoRME9oPzVARgmo6kc9sf3xvlxn/sWb/ FVvsWvBFjLw8UL1R7I5K4tTqUInqmUP/gDkTIg38XpEVdMNdOszmGcoeWJBzYBCt onyRcdqMsyykA36XDLWT7Ft4fPmadWUdnU0OZE+xNqRK366WfCraK9LUtp3mw/xg zSc9aLVuX4uCPmkiezI53NcmXmIuWp/7fxMAqDhAJ4wJQ3b7DlkFqvrWPzXUEBsQ == X-ME-Sender: Received: from [172.20.2.27] (rrcs-24-103-14-244.nyc.biz.rr.com [24.103.14.244]) by mail.messagingengine.com (Postfix) with ESMTPA id 974277E17D for ; Tue, 12 Dec 2017 07:04:21 -0500 (EST) From: Andrus Adamchik Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Re: Queries with joins and entity qualifiers are broken in cayenne-3.1.2 Date: Tue, 12 Dec 2017 07:04:19 -0500 References: To: user@cayenne.apache.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3445.5.20) archived-at: Tue, 12 Dec 2017 12:04:26 -0000 Hi Vladimir, This looks like a bug to me. We'll investigate. Andrus > On Dec 12, 2017, at 6:37 AM, =D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1= =80 =D0=A1=D1=83=D1=85=D0=B8=D0=BD=D0=B8=D0=BD = wrote: >=20 > 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. >=20 > 2017-12-11 17:31 GMT+03:00 =D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1= =80 =D0=A1=D1=83=D1=85=D0=B8=D0=BD=D0=B8=D0=BD = : >=20 >> 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 =3D t1.CUSTOMERID >> AND t0.DELETED =3D 0) >> JOIN GROUP t2 >> ON (t1.GROUPID =3D t2.GROUPID >> AND t0.DELETED =3D 0) >> WHERE (t2.GROUPTYPEID =3D 101100100145) >> AND (t0.DELETED =3D 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 =3D t1.CUSTOMERID >> AND t1.DELETED =3D 0) >> JOIN GROUP t2 >> ON (t1.GROUPID =3D t2.GROUPID >> AND t2.DELETED =3D 0) >> WHERE (t2.GROUPTYPEID =3D 101100100145) >> AND (t0.DELETED =3D 0) >> ORDER BY UPPER(t0.CUSTOMERLASTNAME) >> ; >>=20 >> -- >> Vladimir Suhinin >>=20