• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EO awake ??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EO awake ??


  • Subject: Re: EO awake ??
  • From: Samuel Pelletier <email@hidden>
  • Date: Tue, 06 Sep 2016 14:37:52 -0400

Hi Ted,

The current execution of the code you posted is this:

1- The object is created and inserted

2- Awake from Insertion is called and a Security is created (it was probably null)

3- SetSecurity is called by Person.createPerson method with the provided Security.


So, it the Security object of a Person is not suppose to change, you can put your guard in the setSecurity method.


Samuel


> Le 6 sept. 2016 à 13:08, Theodore Petrosky <email@hidden> a écrit :
>
> 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 <email@hidden> 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 <email@hidden>:
>>>
>>> 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      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >EO awake ?? (From: Theodore Petrosky <email@hidden>)
 >Re: EO awake ?? (From: Theodore Petrosky <email@hidden>)

  • Prev by Date: Re: Code review for refreshToOneRelationshipWithKey
  • Next by Date: Re: ERJavaMail duplicate?
  • Previous by thread: Re: EO awake ??
  • Next by thread: ERJavaMail duplicate?
  • Index(es):
    • Date
    • Thread