Return-Path: Delivered-To: apmail-incubator-cayenne-user-archive@locus.apache.org Received: (qmail 26693 invoked from network); 8 Jun 2006 10:21:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Jun 2006 10:21:58 -0000 Received: (qmail 3685 invoked by uid 500); 8 Jun 2006 10:21:57 -0000 Delivered-To: apmail-incubator-cayenne-user-archive@incubator.apache.org Received: (qmail 3430 invoked by uid 500); 8 Jun 2006 10:21:57 -0000 Mailing-List: contact cayenne-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cayenne-user@incubator.apache.org Delivered-To: mailing list cayenne-user@incubator.apache.org Received: (qmail 3421 invoked by uid 99); 8 Jun 2006 10:21:56 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jun 2006 03:21:56 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=RCVD_IN_BL_SPAMCOP_NET,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of hefest@gmail.com designates 64.233.182.190 as permitted sender) Received: from [64.233.182.190] (HELO nf-out-0910.google.com) (64.233.182.190) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jun 2006 03:21:56 -0700 Received: by nf-out-0910.google.com with SMTP id a27so151244nfc for ; Thu, 08 Jun 2006 03:21:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=gTMfeRe43x6jQOvPpaBS2JHTsRYoRlcHqUTtoV9bA0JKGvejyLHmfTB8o09q3SkRf28x6oGTcfBseQErVd915GJbM9/fUjGTTxwnZaZfRRhdyFeqaeMaHLZRAiDekdq/lKbtBY4KFGgHAEWdRGABXPERKdHl2Yr3+y5T00WDMds= Received: by 10.49.7.1 with SMTP id k1mr1203107nfi; Thu, 08 Jun 2006 03:21:34 -0700 (PDT) Received: by 10.48.206.7 with HTTP; Thu, 8 Jun 2006 03:21:34 -0700 (PDT) Message-ID: Date: Thu, 8 Jun 2006 12:21:34 +0200 From: "Tomi NA" To: cayenne-user@incubator.apache.org Subject: Re: very, very serious problem - null values where objects should be In-Reply-To: <9D936B36-796E-4206-9BBA-EBE8785165C8@objectstyle.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <46FCBD16-A5C5-48C4-A69A-F7B5B8A5E062@gmail.com> <121661B7-4E69-4B82-8B6E-6C7F04FF54DD@objectstyle.org> <9D936B36-796E-4206-9BBA-EBE8785165C8@objectstyle.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On 6/6/06, Andrus Adamchik wrote: > > On Jun 5, 2006, at 7:34 PM, Tomi NA wrote: > > > How would this provide more information than monitoring > > setToObjectGroup() execution? Where is writeProperty used outside of > > the setters? > > The framework can access objects bypassing the setters (e.g. this is > how Generic Persistent Class operates [1], but this is also true for > any DataObject). > > So since I don't know how your code is written, I am making general > assumptions going from Cayenne end. There are two suspects. First is > that the relationship is nullified indirectly by Cayenne in response > to a sequence of events in the application. One more level down this > path - can you try putting a thread dump in 'writePropertyDirectly' > overriden method and see if it shows anything. > > Second is that serialization is somehow involved, as deserialization > accesses fields directly. > > These are the two ways to bypass the setters. Otherwise I am out of > ideas (without looking at the code that is). I've narrowed the problem down and now that I've done it, I can't believe what I'm seeing. I noticed that the problem occurs when I run my "advanced search". Once I run it, I can isolate an object (just one of many) whose relations have been set to null. I then proceeded to System.out.println(object.getToGroup().getToGroupCluster().getName()) debugging, for reasons that are unlikely to become obvious at the moment. The idea of the code snippet is to fill the objList List with all instances of level 1 objects, something along the lines "for the given level4 object, get all level3 objects and for every level3 object get all level2 objects and for all level2 objects, get all level 1 objects." Now, the debug statements inserted like this don't throw a java.lang.NullPointerException: List level3Objects = criteria.getLevel4Object().getLevel3ObjectArray(); for (Level3Object u : level3Objects) { List level2Objects = u.getLevel2ObjectArray(); // 2 DEBUGGING STATEMENTS: Level1Object l1o = (Level1Object) DataObjectUtils.objectForPK(context, Level1Object.class, 31332); System.out.println(l1o.getToLevel2Object().getToLevel3Object().getName()); for (Level2Object l2o : level2Objects) { objList.add(l2o); } } However, when I move the two debugging statements into the following for-loop, I get the NullPointerException on the System.out.println(...) because getLevel3Object() is null and therefore can't call it's getName() method: List level3Objects = criteria.getLevel4Object().getLevel3ObjectArray(); for (Level3Object u : level3Objects) { List level2Objects = u.getLevel2ObjectArray(); for (Level2Object l2o : level2Objects) { Level1Object l1o = (Level1Object) DataObjectUtils.objectForPK(context, Level1Object.class, 31332); System.out.println(l1o.getToLevel2Object().getToLevel3Object().getName()); objList.add(l2o); } } I can't for the life of me guess what the final for-loop does that nullifies the relevant object relationship. t.n.a.