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 18193751F for ; Tue, 6 Sep 2011 15:39:51 +0000 (UTC) Received: (qmail 4430 invoked by uid 500); 6 Sep 2011 15:39:50 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 4357 invoked by uid 500); 6 Sep 2011 15:39:50 -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 4349 invoked by uid 99); 6 Sep 2011 15:39:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2011 15:39:49 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [209.86.89.69] (HELO elasmtp-mealy.atl.sa.earthlink.net) (209.86.89.69) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2011 15:39:40 +0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=earthlink.net; b=ti8p5Fc262Hjeixremoajo6vMjWpkauujL4UK5hZNIZpxlM7yxdQk4g4uW0/jeFX; h=Received:Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer:X-ELNK-Trace:X-Originating-IP; Received: from [70.160.22.63] (helo=[192.168.1.103]) by elasmtp-mealy.atl.sa.earthlink.net with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.67) (envelope-from ) id 1R0xk6-0005TW-Vr for user@cayenne.apache.org; Tue, 06 Sep 2011 11:39:19 -0400 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1244.3) Subject: Re: Getting null instead of the actual value From: Joe Baldwin In-Reply-To: Date: Tue, 6 Sep 2011 11:39:18 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: user@cayenne.apache.org X-Mailer: Apple Mail (2.1244.3) X-ELNK-Trace: 74aacf41df18ac9f85338a7d01cb3b6a7e972de0d01da940154eaca72f44181c1f1a2cdf8a715964350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 70.160.22.63 X-Virus-Checked: Checked by ClamAV on apache.org Christian, It is a tad difficult to follow all of your pseudo-code (as with all = pseudo-code), but it appears that you are adding to "UserRoles" object = via Cayenne and that you have left out the step to "commitChanges" on = your ObjectContext. Here is the basic pseudo code for Cayenne usage model: 1. get your ObjectContext (ex: BaseContext.getThreadObjectContext();) 2. create a new entity on the OC (ex: = (UserRoles)oc.newObject(UserRoles.class);) 3. initialize your entity with values 4. commit changes (ex: oc.commitChanges();) Totally easy! :) Joe On Sep 6, 2011, at 11:14 AM, Christian Grobmeier wrote: > Folks, >=20 > I need your help. An error in my app bugs me and I am looking > desperately were it could happen. >=20 > The use case is: > - create a user > - create a user_role object > - select one of the existing roles > - connect all together and commit >=20 > I see that all values are correct in the database (mysql console) >=20 > But after the user registered, my app fails with the error "no role". >=20 > What I do is basically: >=20 > ur =3D User.getUserRoles(); > foreach ur: > r =3D ur.getRole() >=20 >=20 > 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? >=20 > I add a role to a user liek this: >=20 > User user ... >=20 > UserRoles userRoles =3D new UserRoles(); > userRoles.setUser(user); > userRoles.setRole(role); > user.addToUserRoles(userRoles); > role.addToRolesToJoin(userRoles); >=20 > Any hints highly apprecitated - thanks in advance >=20 > Christian