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 74EC77AC6 for ; Fri, 16 Sep 2011 19:17:09 +0000 (UTC) Received: (qmail 83725 invoked by uid 500); 16 Sep 2011 19:17:09 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 83701 invoked by uid 500); 16 Sep 2011 19:17:09 -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 83692 invoked by uid 99); 16 Sep 2011 19:17:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Sep 2011 19:17:09 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 16 Sep 2011 19:17:03 +0000 Received: (qmail 11347 invoked from network); 16 Sep 2011 19:16:39 -0000 Received: from unknown (HELO ?127.0.0.1?) (127.0.0.1) by localhost with SMTP; 16 Sep 2011 19:16:39 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: Getting null instead of the actual value From: Andrus Adamchik In-Reply-To: Date: Fri, 16 Sep 2011 22:16:40 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <4654784B-B27F-46A0-853D-2931FFA306AD@objectstyle.org> References: <480D6A08-A61C-4F8A-B72D-BF8175A1A1E4@objectstyle.org> <4F560F6C-51CD-4B38-83E1-AE4178E0816B@objectstyle.org> <5A179745-EE5A-486C-994E-6EC4D6CA25C3@objectstyle.org> To: user@cayenne.apache.org X-Mailer: Apple Mail (2.1084) X-Virus-Checked: Checked by ClamAV on apache.org One side of prefetching is saving us uneeded queries, when we know = upfront which related objects we need in addition to the main query = result. This is the angle shown in the docs where prefetching is = presented as a performance optimization tool.=20 But there is another side of it, which is just as important. It is about = fine-grained control of refreshing parts of the object graph already in = memory. When a query is run, Cayenne can't automatically refresh all = objects directly or indirectly connected to the query result objects, as = it would cause a massive fetch. With prefetching Cayenne knows how much = of the object graph we want to refresh. So I don't find the result all that surprising. (Although if things = happen in the same JVM I am still surprised the relationship isn't = refreshed via Cayenne cross-context event mechanism. This could be a = race condition actually, as events are delivered asynchronously) Andrus=20 On Sep 16, 2011, at 10:01 PM, Christian Grobmeier wrote: > I have not had duplication issues so far. But I will double check now. > I added this code b/c of the problems with the null values, so it isnt > the root cause for my problem. > At the moment it still looks good. It seems that the prefetch helped. > I am very puzzled about it :-) >=20 > On Fri, Sep 16, 2011 at 8:30 PM, Michael Gentry = wrote: >> I seem to recall doing a setX() followed by an addToY() causes a >> duplicate Y to be added. I'd have to double check this, but that is >> my recollection. >>=20 >> On Fri, Sep 16, 2011 at 2:19 PM, Andrus Adamchik = wrote: >>>> but may cause duplication issues for addToY(). >>>=20 >>> I hope it doesn't. But since I am trained to just set the rel in one = direction, I may not be aware of the issue. >>>=20 >>>=20 >>> On Sep 16, 2011, at 9:12 PM, Mike Kienenberger wrote: >>>=20 >>>> On Fri, Sep 16, 2011 at 4:22 AM, Christian Grobmeier >>>> wrote: >>>>> userRoles.setUser(user); >>>>> userRoles.setRole(role); >>>>> user.addToUserRoles(userRoles); >>>>> role.addToRolesToJoin(userRoles); >>>>=20 >>>> Again, unless, you've specifically made both relationships >>>> unidirectional (the default is bidirectional), you are actually >>>> setting both sides of the relationship twice. Not an issue for a >>>> SetX(), but may cause duplication issues for addToY(). >>>>=20 >>>=20 >>>=20 >>=20 >=20 >=20 >=20 > --=20 > http://www.grobmeier.de >=20