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 C0DB083BA for ; Tue, 13 Sep 2011 13:48:04 +0000 (UTC) Received: (qmail 58208 invoked by uid 500); 13 Sep 2011 13:48:04 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 58186 invoked by uid 500); 13 Sep 2011 13:48:04 -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 58178 invoked by uid 99); 13 Sep 2011 13:48:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2011 13:48:04 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of grobmeier@gmail.com designates 209.85.160.171 as permitted sender) Received: from [209.85.160.171] (HELO mail-gy0-f171.google.com) (209.85.160.171) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2011 13:47:58 +0000 Received: by gyh3 with SMTP id 3so612249gyh.16 for ; Tue, 13 Sep 2011 06:47:38 -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=11gvky6rxlssKfgWyDlB5RAZSeqNbmwp0liSi5kQ8gg=; b=mHaSTMhD2bRVhiYZ3sYyJe6aikbztIShlw3x5Fe37A2nRvTW28DpqDQHX139+4gA1l w/a51BCL8b/lq+auVvAFbkaygGFZPyt0TQkmEm2GNh1c6dKs43tF5I9Q9gbRpOw/YZs+ 24nb2J3ix4zFFGncNsSMY59EVBnFvS8hig2hk= Received: by 10.42.108.71 with SMTP id g7mr2708046icp.436.1315921658077; Tue, 13 Sep 2011 06:47:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.177.197 with HTTP; Tue, 13 Sep 2011 06:47:18 -0700 (PDT) In-Reply-To: References: From: Christian Grobmeier Date: Tue, 13 Sep 2011 15:47:18 +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 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 wrot= e: > 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 >> > --=20 http://www.grobmeier.de