Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E0DA89498 for ; Sun, 6 Nov 2011 17:37:52 +0000 (UTC) Received: (qmail 48782 invoked by uid 500); 6 Nov 2011 17:37:52 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 48744 invoked by uid 500); 6 Nov 2011 17:37:52 -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 48736 invoked by uid 99); 6 Nov 2011 17:37:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Nov 2011 17:37:52 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of grobmeier@gmail.com designates 209.85.216.171 as permitted sender) Received: from [209.85.216.171] (HELO mail-qy0-f171.google.com) (209.85.216.171) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Nov 2011 17:37:46 +0000 Received: by qyg36 with SMTP id 36so2407476qyg.16 for ; Sun, 06 Nov 2011 09:37:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=U+jYDVo923JEHAarGLECRJ4RrT7Yge/7E+qsEWcCYOw=; b=TGMBI2Z8czH30EQv4M38TFg/+9gAK4OhPRKABuWjsXgsuLVgUlF07coVsF82zSUXn9 Zd1kgrY3I+yxag4CqbRbRBf2HeDNWt3V2dcOCK5NwJZTb4d1Anypel0pPsGGhkoQe/4q q1F6mVZnVNy1X94d2XbHu91CyxL67hU69FIGg= Received: by 10.229.2.193 with SMTP id 1mr2674950qck.35.1320601045207; Sun, 06 Nov 2011 09:37:25 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.47.67 with HTTP; Sun, 6 Nov 2011 09:37:04 -0800 (PST) In-Reply-To: <007B1256-8707-448D-8BE6-B40BF1BA54F4@apple.com> References: <007B1256-8707-448D-8BE6-B40BF1BA54F4@apple.com> From: Christian Grobmeier Date: Sun, 6 Nov 2011 18:37:04 +0100 Message-ID: Subject: Re: Selecting relationships without restriction To: user@cayenne.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi Joe, thanks for letting me know. This would be a killer feature. Cheers, Christian On Sun, Nov 6, 2011 at 5:35 PM, Joseph Senecal wrote: > Christian, > > There is no way that I know of to specify additional qualifiers to Cayenn= e's built in relationships. The design is that getPrices should return all = prices where Price.article field has been set to that article. > > What you can do is add your own method getCurrentPrices that returns all = non-historic prices. This could either explicitly run a query looking for A= rticle.articleID =3D Price.articleID and Price.historic is false or null. O= r you can filter though the list of all Prices to select the prices which a= ren't historic. > > The second option has the advantage that it will automatically notice whe= n new prices are added or old prices are marked as historic. > > The first option has the advantage that it doesn't load all prices into m= emory, but it doesn't return unsaved current prices. And if the result is c= ached, it doesn't reflect any changes. > > Joe > > On Nov 6, 2011, at 8:04 AM, Christian Grobmeier wrote: > >> Hi all, >> >> I have two tables Article and Price. >> The table Price can containt historic prices which should not be selecte= d. >> >> I do something like that: >> >> Expression expression =3D ExpressionFactory.matchExp("prices.historic", = false); >> Expression fullExp =3D >> expression.orExp(ExpressionFactory.matchExp("prices+.historic", >> null)); >> SelectQuery query =3D new SelectQuery(Module.class, fullExp); >> List list =3D ctx.performQuery(query); >> >> This generates a correct sql like: >> >> SELECT DISTINCT t0....* >> FROM articles t0 >> LEFT JOIN prices t1 ON (t0.id =3D t1.article_id) >> WHERE (t1.historic =3D false) OR (t1.historic IS NULL) >> >> Using that sql works well on my MySQL db directly. >> >> When I run Cayenne, my junit test case fails because I when I call >> getPrices() I get even the historic ones. >> >> For example: >> >> List list =3D ctx.performQuery(query); >> Article a =3D (Article)list.get(0); >> a.getPrices(); // <--- returns historic true/false >> >> I had the expectation that the historic prices should not appear here. >> Do I miss something? >> >> Cheers, >> Christian > > --=20 http://www.grobmeier.de