cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
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:

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 <tgiaccone@gmail.com> 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
>

Mime
View raw message