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 035DACA0F for ; Mon, 5 Aug 2013 23:32:55 +0000 (UTC) Received: (qmail 27114 invoked by uid 500); 5 Aug 2013 23:32:54 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 27064 invoked by uid 500); 5 Aug 2013 23:32:54 -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 27054 invoked by uid 99); 5 Aug 2013 23:32:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Aug 2013 23:32:54 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [209.85.212.42] (HELO mail-vb0-f42.google.com) (209.85.212.42) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Aug 2013 23:32:49 +0000 Received: by mail-vb0-f42.google.com with SMTP id e12so3510769vbg.29 for ; Mon, 05 Aug 2013 16:32:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:x-gm-message-state; bh=QgnpEoJvuN/Tb5/5dYsYddAVCSvTIWxEmfDyi/Jyrls=; b=IYUVxUSBy0IDD8wavCN4gnP0ph5JKgl2CcYrGBo6Z3rgukg/COiXiOiS67mto5Et4B t787PWJBFHL0fwAhXZ+Eewkhx435zSIOpXtm2lnv5hwqVoeNLJ1p8UMyPiqnOKPni2+O fFLYhQ3DMCn8qNDfTKWNseJ501Bdu9i1a2o9H210kedzS4UsiAl7glC7+jQJNdQF9DLa Ps5/RUKRzLZjLyjJdcW2OXvY62d5dKEawVKl0eajYZHAgRGIB3Ohhi4kygEJIMR/ek4x 241busv6yrK3O88Ou28QwA5dB5D38dm9SifMxlK1s4dRMGUS3Ky2tBctAoedxKKFtld+ n7hg== X-Received: by 10.58.13.41 with SMTP id e9mr6447978vec.81.1375745527877; Mon, 05 Aug 2013 16:32:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.58.75.75 with HTTP; Mon, 5 Aug 2013 16:31:47 -0700 (PDT) In-Reply-To: References: From: Michael Gentry Date: Mon, 5 Aug 2013 19:31:47 -0400 Message-ID: Subject: Re: Flattened relationships To: Cayenne Users Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQn3eqnLB3ptjsGO6vFdFmYxm02YMKzmEwQXTZ7+Z1acmiZbqC4XgHmNqOdkgzNaiG2gFJc0 X-Virus-Checked: Checked by ClamAV on apache.org Hi Tony, Does your UserRole have more than 2 FKs in it? Did you map UserRole to a Java class in addition to the DB mapping or do you just have the DB mapping? You should be able to do what you want. I happen to have an old working example here that does exactly what you are describing: https://github.com/mrg/cbe/blob/master/InsertingObjects/ManyToMany/src/main/java/cbe/inserting/ManyToMany.java The complete project has a model you can reference, too. mrg On Mon, Aug 5, 2013 at 7:03 PM, Tony Giaccone wrote: > > I have a User a Role and a UserRole. UserRole represents the Join Table between the two. > > The User has a flattened relationship through UserRole to Roles. It's marked as to many, list. > > The Role had a flattened relationship to Users it's marked in the modeler as to many, read-only, list. > > > I want to add a standard role to the user. I fetch the role, create the user. The use: > > newUser.addToRoles(userRole); > context.commitChanges(); > > And an exception gets thrown. > > Cannot set the read-only flattened relationship 'users' in ObjEntity 'Role' > > What am I missing? Do I need accessors for the UserRole? I thought I could Dispose of that class. I'm confused. > > Tony Giaccone >