On 17/11/2011, at 1:21 PM, Chuck Hill wrote:

>>>> Say I have two entities, User and Role, and a joining entity UserRole to 
>>>> create a many-to-many relationship between them.  So I have a relationship 
>>>> 'userRoles' from User to UserRole (and a relationship 'userRoles' from 
>>>> Role back to UserRole).  I flatten the relationship on User, so I also 
>>>> have a 'roles' relationship on that entity.
> 
> So User.userRoles and Role.userRoles are not class attributes, right?  They 
> are just modelled.  User.roles and Role.users are the to-many relationships 
> that you see in the Java code.

Correct.

>>>> Say I delete a User.  I want User.userRoles to Cascade.  And I want both 
>>>> UserRole.user and UserRole.role to Nullify.  And at that point, isn't the 
>>>> work done?  So in this case, wouldn't I want No Action on User.roles?  And 
>>>> hence isn't this a counter-example to your advice above?  (It may well not 
>>>> be—tell me if I'm wrong!)
> 
> This is making my head hurt.  I have the public to-many User.roles as Nullify.

Yeah, that's what Entity Modeler will give you as the default.

> I was under the impression that you needed that to remove that User from the 
> Role.users relationship.  But I could be wrong.  That might just be a habit.

I forced myself to sit down and write a test app.  You're completely correct.  
Problem solved.

> The non-class attribute User.userRoles is set to Cascade.  The to-one 
> relationships from UserRole to User and to Role is Nullify.

(Yeah.)

To summarise, my original question amounted to, "Do you really need to think 
about whether the delete rules on the flattened and the underlying 
relationships are consistent, couldn't you just set the flattened to No 
Action?"  And the answer is: "No, you really need to think about it and make 
sure they're consistent."

Thanks Ramsey, Dave, and Chuck.


-- 
Paul.

http://logicsquad.net/


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to