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 398E18E9C for ; Tue, 13 Sep 2011 15:21:24 +0000 (UTC) Received: (qmail 95329 invoked by uid 500); 13 Sep 2011 15:21:24 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 95237 invoked by uid 500); 13 Sep 2011 15:21: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 95227 invoked by uid 99); 13 Sep 2011 15:21:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2011 15:21:24 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of grobmeier@gmail.com designates 74.125.83.43 as permitted sender) Received: from [74.125.83.43] (HELO mail-gw0-f43.google.com) (74.125.83.43) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2011 15:21:17 +0000 Received: by gwm11 with SMTP id 11so690203gwm.16 for ; Tue, 13 Sep 2011 08:20:56 -0700 (PDT) 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=avvYuv4hAadv+A7sHkuozhE4//oZ41J1SCtV3PP3Kws=; b=Tj+/X8rPGug7axsZVedo+/H4K1es/dqwQ9HUibk6h9ogGSNibwWNrWqsnxM1gOfOtj 1KuAX52VLUxBqaKhrLtXgrrOu3RnB3XwDhmO01L1TDVFNVdlJ7qTUZDDqYezBB6wm2Dl h3BWjckHJ7Bm5OWbmb/rAiy2UWnI9svZGNR0o= Received: by 10.42.101.81 with SMTP id d17mr2119831ico.168.1315927255196; Tue, 13 Sep 2011 08:20:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.177.197 with HTTP; Tue, 13 Sep 2011 08:20:35 -0700 (PDT) In-Reply-To: <480D6A08-A61C-4F8A-B72D-BF8175A1A1E4@objectstyle.org> References: <480D6A08-A61C-4F8A-B72D-BF8175A1A1E4@objectstyle.org> From: Christian Grobmeier Date: Tue, 13 Sep 2011 17:20:35 +0200 Message-ID: Subject: Re: Getting null instead of the actual value 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 Andrus, thanks for the comments. I will check that again and come back on thursday with the answer (currently on travel). What bugs me really is that it works sometimes, and sometimes not. Can this behavior be explained with Michaels/your suggestions? Cheers On Tue, Sep 13, 2011 at 4:09 PM, Andrus Adamchik w= rote: > I haven't read the entire thread, only the messages quoted below. > > Michael's advise is absolutely correct. However the initial code worked b= ecause the Role was likely already registered in the context, so the UserRo= les was pulled automatically in the same context. > > So ... a few things to check: > > 1. Can you confirm in DB that there's no userrole records with NULL rolei= d? > 2. The mapping - if you could post the XML of all 3 DbEntity/ObjEntity ma= ppings with their relationships it may shed some light on this problem. > 3. The context - what happens between commit and access of the role objec= t (serialization/deserialization? Are you working with the same ObjectConte= xt and the same instances of all objects, or are you refetching them fresh?= Same ObjectContext or different ones)? > > Andrus > > > On Sep 13, 2011, at 4:47 PM, Christian Grobmeier wrote: >> Hi folks, >> >> i tried this, i didn't work. Any more ideas? >> One thing I should note: it doesn'ht happen all the time >> unfortunately. Its only sometimes and I really don't know why. >> >> More ideas appreciated.... >> >> Cheers >> Christian >> >> >> >> On Tue, Sep 6, 2011 at 5:42 PM, Michael Gentry w= rote: >>> Hi Christian, >>> >>> I suspect it is because you are creating the UserRole outside the >>> DataContext. =C2=A0Try something like: >>> >>> UserRoles userRoles =3D user.getObjectContext.newObject(UserRoles.class= ); >>> userRoles.setUser(user); >>> userRoles.setRole(role); >>> >>> mrg >>> >>> >>> On Tue, Sep 6, 2011 at 11:14 AM, Christian Grobmeier >>> wrote: >>>> Folks, >>>> >>>> I need your help. An error in my app bugs me and I am looking >>>> desperately were it could happen. >>>> >>>> The use case is: >>>> - create a user >>>> - create a user_role object >>>> - select one of the existing roles >>>> - connect all together and commit >>>> >>>> I see that all values are correct in the database (mysql console) >>>> >>>> But after the user registered, my app fails with the error "no role". >>>> >>>> What I do is basically: >>>> >>>> ur =3D User.getUserRoles(); >>>> foreach ur: >>>> =C2=A0 r =3D ur.getRole() >>>> >>>> >>>> And the r reference is null. I am not sure what I am doing wrong. Any >>>> hints what I could check in my Cayenne app? >>>> >>>> I add a role to a user liek this: >>>> >>>> User user ... >>>> >>>> UserRoles userRoles =3D new UserRoles(); >>>> userRoles.setUser(user); >>>> userRoles.setRole(role); >>>> user.addToUserRoles(userRoles); >>>> role.addToRolesToJoin(userRoles); >>>> >>>> Any hints highly apprecitated - thanks in advance >>>> >>>> Christian >>>> >>> >> >> >> >> -- >> http://www.grobmeier.de >> > > --=20 http://www.grobmeier.de