cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <>
Subject Re: Flattened relationships
Date Mon, 05 Aug 2013 23:31:47 GMT
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:

The complete project has a model you can reference, too.


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,
> 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

View raw message