Re: Saving entities problem [SOLVED]
Re: Saving entities problem [SOLVED]
- Subject: Re: Saving entities problem [SOLVED]
- From: Art Isbell <email@hidden>
- Date: Mon, 28 Jul 2003 12:02:10 -1000
On Monday, July 28, 2003, at 06:21 AM, Jevon Hills wrote:
And set it's values
at.setPermission(canUse);
at.setApplications(mlp);
at.setUsers(aUsers);
And then save the changes
again(this.session().defaultEditingContext().saveChanges();)
**This Does not work.
On Monday, July 28, 2003, at 07:31 AM, Jevon Hills wrote:
The problem I had was my 3 FK columns would not accept nulls in either
the DB or the EOModel. When I was generating the object these of
course were null vaulus until the sql is generated. By allowing nulls
these worked just fine.
These primary key values should not be null, so I suspect by allowing
these to be null, you may be covering up another problem that will come
back to haunt you later (they always do :-)
The problem might be a modeling problem. EOModeler supports a
2-entity many-to-many relationship, but not a 3-entity many-to-many
relationship as in your case. So you'll need to build this manually.
This can be very tricky to do correctly. What I've done in similar
situations is let EOModeler build a 2-entity many-to-many relationship
and then copy exactly what EOModeler did but with 3 entities. This
requires examining each relationship EOModeler creates, setting the
relationship delete rules, propagate primary key property, etc.,
flattening proper relationships, ensuring that both the flattened and
underlying relationships aren't both class properties, etc.
The other problem might be your code. You shouldn't use relationship
setter methods directly; instead use
addObjectToBothSidesOfRelationshipWithKey(). This method will use
setter methods for both sides of each relationship; i.e. the
relationship and its inverse, if any. Failure to set both sides of
each relationship can result in the object graph being incomplete which
can lead to SQL that doesn't set database values correctly.
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.