On 2011-11-09, at 4:08 PM, Paul Hoadley wrote:

> On 10/11/2011, at 8:25 AM, Ramsey Gurley 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.


>>> 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.  
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.  
The non-class attribute User.userRoles is set to Cascade.  The to-one 
relationships from UserRole to User and to Role is Nullify.


>> 
>> I looked a second time.  The cascade is actually on the non-class property.  
>> The flattened is nullify... so maybe it would work with no action.  I'm not 
>> recommending anything, just noting something I saw which seemed odd.
> 
> Sorry, not trying to pin you down to anything!  In my example above, because 
> UserRole.role is Nullify, probably having User.roles set to Nullify would not 
> make any difference.  I would have to work a bit hard to contrive an example 
> where it mattered.  Say if UserRole.role was Cascade (obviously it wouldn't 
> be)—then if User.roles was Nullify they would conflict, but if it was No 
> Action, the Cascade would happen.
> 
> Obviously you could look at each flattened relationship on a case-by-case 
> basis.  I'm just trying to tease out whether No Action would be correct 100% 
> of the time, as long as you had the right delete rules along the chain of 
> actual relationships that constituted the flattened relationship.
> 


-- 
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall 
knowledge of WebObjects or who are trying to solve specific problems.    
http://www.global-village.net/products/practical_webobjects







 _______________________________________________
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