Hi all,

I think there is another condition to met for the automatic creation. The 
primary key of the source should also be the foreign key to the destination 
entity.

Own destination means that the destination object is owned by the source and 
should be deleted when removed from the relationship.

This works for toOne and toMany and I think create more confusion than solve 
problems... You should make sure a object is never passed to another owner 
because it will be deleted in the process.

Samuel



> Le 12 sept. 2016 à 11:31, Theodore Petrosky <tedp...@yahoo.com> a écrit :
> 
> Chuck, could you expound a little here? I refer to “An owned, mandatory, 
> to-one will get created automatically by EOF”
> 
> Maybe I am not modeling this correctly. I am creating a person entity and a 
> security entity. then I create a relationship of person to-one security where 
> security can not be null. (optional is not selected)
> 
> In my D2W app, if I create a new person, the security entity relation is not 
> automatically created. I thought I had to create this in the EO’s init, or 
> awakeFromInsertion methods.
> 
> Am I supposed to do something more to the model to make this “automatic”?
> 
> Ted
> 
> 
> 
>> On Sep 6, 2016, at 2:14 PM, Chuck Hill <ch...@gevityinc.com 
>> <mailto:ch...@gevityinc.com>> wrote:
>> 
>> Did you do the check for null after the call to super? 
>>  
>> An owned, mandatory, to-one will get created automatically by EOF.  I am 
>> pretty sure that is what is happening and then you are creating and 
>> assigning a second one.
>>  
>> Chuck
>>  
>>  
>> From: <webobjects-dev-bounces+chill=gevityinc....@lists.apple.com 
>> <mailto:webobjects-dev-bounces+chill=gevityinc....@lists.apple.com>> on 
>> behalf of Theodore Petrosky <tedp...@yahoo.com <mailto:tedp...@yahoo.com>>
>> Date: Tuesday, September 6, 2016 at 10:08 AM
>> To: Johann Werner <j...@oyosys.com <mailto:j...@oyosys.com>>
>> Cc: WebObjects-Dev <webobjects-dev@lists.apple.com 
>> <mailto:webobjects-dev@lists.apple.com>>
>> Subject: Re: EO awake ??
>>  
>> I tried the first suggestion of wrapping the createSecurity in a check to 
>> see if it is null and I got the same result.
>>  
>> then I moved the createSecurity method call into the init method and I get 
>> the same issue. I could probably trick it by making the security entity not 
>> mandatory. but as the createSecurity is in the init call, the person will 
>> always get a security.
>>  
>> Ted
>>  
>>  
>> On Sep 6, 2016, at 12:44 PM, Johann Werner <j...@oyosys.de 
>> <mailto:j...@oyosys.de>> wrote:
>> Hi Ted,
>> why not just check if there is already a value in your awakeFromInsertion?
>> public void awakeFromInsertion(EOEditingContext editingContext) {
>>     super.awakeFromInsertion(editingContext);
>>     if (security() == null) {
>>          setSecurity(Security.createSecurity(editingContext, true, true, 
>> true, true, true));
>>     }
>> }
>> But probably you should be using the init(EOEditingContext editingContext) 
>> method instead, which is highly advisable.
>> jw
>> Am 06.09.2016 um 18:27 schrieb Theodore Petrosky <tedp...@yahoo.com 
>> <mailto:tedp...@yahoo.com>>:
>> I have a to one relation Person to one Security. I keep all my security 
>> booleans in entity Security.
>> I am overriding awakeFromInsertion so that when I create a new person, it is 
>> assigned a security entity.
>> I have a problem in migrations. I have a postupgrade method that creates a 
>> person. in this method I have:
>>        Person.createPerson(editingContext, new NSTimestamp(), "Theodore", 
>> true, "Petrosky", “pw", “user", Security.createSecurity(editingContext, 
>> true, true, true, true, true));
>> the security is mandatory as it should be. However on first run (to run the 
>> migrations), I end up with two security entities. Obviously, when a person 
>> is created and inserted the awake is fired and I get this orphan.
>> How can I eliminate this extra security entity? I was hoping that I could 
>> just not add a security entity in the createPerson line, but then my app 
>> complains that security is mandatory.
>> Person.createPerson(editingContext, new NSTimestamp(), "Theodore", true, 
>> "Petrosky", “pw", “user”, null);
>> In the past I would have just used ERXJDBCUtilities.executeUpdate and added 
>> the admin user with manual sql. I thought I would be clever and use the 
>> postupgrade method.
>>  
>>  
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com 
>> <mailto:Webobjects-dev@lists.apple.com>)
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/chill%40gevityinc.com 
>> <https://lists.apple.com/mailman/options/webobjects-dev/chill%40gevityinc.com>
>>  
>> This email sent to ch...@gevityinc.com <mailto:ch...@gevityinc.com>
> _______________________________________________
> 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:
> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
> 
> This email sent to sam...@samkar.com

 _______________________________________________
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:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

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

Reply via email to