Re: invalidate relationship cache

2018-03-05 Thread Aaron Rosenzweig
Hi Chris,

If you the “color” attribute was originally “red” when it was fetched an hour 
ago but in the unsaved EO object cache you changed it to “blue” …. and now you 
fetched from the DB and someone else made it “yellow”…. you want to know what 
will happen?

Try it :-)

I’m actually not sure but I think it will try to merge in your unsaved changes 
with the new reality but when conflicts occur I’m not sure if it would throw 
out your edits. It might. 

If it does throw out your edits then you’d have to resort to raw rows which 
isn’t evil… it has no caching, and gives you just what you need. If you don’t 
want a cache then don’t use one! Raw Rows to the rescue. 

There are only two difficult things in software:

1) cache invalidation. 

2) naming sh$t

3) off-by-one errors
AARON ROSENZWEIG / Chat 'n Bike <http://www.chatnbike.com/>
e:  aa...@chatnbike.com <mailto:aa...@chatnbike.com>  t:  (301) 956-2319



> On Mar 5, 2018, at 2:48 PM, Lonie, Chris  wrote:
> 
> Aaron,
>  
> Doesn’t this reset the values in the first object to those that are in the 
> DB? So, depending on André’s flow, this could cause issues (or opportunities, 
> depending on how many management classes you’ve taken).
>  
> Thanks,
> Chris
>  
> From: Webobjects-dev 
> [mailto:webobjects-dev-bounces+chris.lonie=hpe@lists.apple.com] On Behalf 
> Of Aaron Rosenzweig
> Sent: Monday, March 05, 2018 2:41 PM
> To: Chuck Hill 
> Cc: webobjects-dev@lists.apple.com
> Subject: Re: invalidate relationship cache
>  
> Hi André and Chuck,
>  
> I asked my wife about invalidating the relationship cache.
>  
> She looked at me and said:
>  
> “Love is grand, divorce is 100 grand”
>  
> I would:
>  
> 1) create a fetch specification
>  
> 2) set “refreshesRefetchedObjects()” to true.
>  
> 3) set up a prefetch path that traverses to the second objects.
>  
> Then use the editing context to fetch.
>  
> EOQualifier identityQualifier = {set this up yourself}
> EOFetchSpecification fetchSpec = new EOFetchSpecification(YourEO.ENTITY_NAME, 
> identityQualifier, null /*sortOrderings*/);
> fetchSpec.setRefreshesRefetchedObjects(true);
> fetchSpec.setPrefetchingRelationshipKeyPaths(new NSArray(
> 
> YourEO.RELATIONSHIP_NAME.dot(OtherEO.RELATIONSHIP_NAME).key()
> )
> );
> editingContext.objectsWithFetchSpecification(fetchSpec);
> 
> 
> NOTE: Your identity qualifier might be like so:
>  
> EOEntity entity = EOUtilities.entityForObject(yourEO.editingContext(), 
> yourEO);
> EOKeyGlobalID globalID = (EOKeyGlobalID) 
> eo.editingContext().globalIDForObject(eo);
> NSDictionary primaryKey = 
> entity.primaryKeyForGlobalID(globalID);
> EOQualifier identityQualifier = entity.qualifierForPrimaryKey(primaryKey);
>  
> profit - save yourself 100 grand. 
> AARON ROSENZWEIG / Chat 'n Bike <http://www.chatnbike.com/>
> e:  aa...@chatnbike.com <mailto:aa...@chatnbike.com>  t:  (301) 956-2319
> 
> 
> 
> 
> 
> 
> 
> On Mar 5, 2018, at 2:24 PM, Chuck Hill  <mailto:ch...@gevityinc.com>> wrote:
>  
> Hi André,
> 
> Invalidating the GlobalIds won’t work.  That will just refresh the objects 
> that you have a list of already.  From your description, I think that you 
> want to refresh what is in list (get an updated list with inserted and 
> deleted rows that match the databse).  This should work
> ERXEOControlUtilities. clearSnapshotForRelationshipNamed(eo, " extWsProjects 
> ");
> 
> Following that you many need to refault the objects in the relationship.
> 
> 
> 
> On 2018-03-05, 8:31 AM, "Webobjects-dev on behalf of André Rothe" 
>  <mailto:webobjects-dev-bounces+chill=gevityinc@lists.apple.com> on behalf 
> of andre.ro...@zks.uni-leipzig.de <mailto:andre.ro...@zks.uni-leipzig.de>> 
> wrote:
> 
>Hi,
> 
>I have an EO with a relationship to a second EO. The database in the
>background will be changed by another application, so it will be
>necessary to refetch the associated EOs of the relationship on every
>access.
> 
>How I can invalidate the list of the associated EOs?
> 
>This is the generated method (EOGenerator):
> 
>public NSArray extWsProjects() {
> // TODO: invalidate this array
> return (NSArray)storedValueForKey("extWsProjects");
>}
> 
>On the page
>
> https://en.wikibooks.org/wiki/WebObjects/EOF/Using_EOF/Caching_and_Freshness 
> <https://en.wikibooks.org/wiki/WebObjects/EOF/Using_EOF/Caching_and_Freshness>
> 
>I read something from Jesse Barnum, should I get all the ExtWsProject
>objects and their GIDs to c

Re: invalidate relationship cache

2018-03-05 Thread Aaron Rosenzweig
Hi André and Chuck,

I asked my wife about invalidating the relationship cache.

She looked at me and said:

“Love is grand, divorce is 100 grand”

I would:

1) create a fetch specification

2) set “refreshesRefetchedObjects()” to true.

3) set up a prefetch path that traverses to the second objects.

Then use the editing context to fetch.

EOQualifier identityQualifier = {set this up yourself}
EOFetchSpecification fetchSpec = new EOFetchSpecification(YourEO.ENTITY_NAME, 
identityQualifier, null /*sortOrderings*/);
fetchSpec.setRefreshesRefetchedObjects(true);
fetchSpec.setPrefetchingRelationshipKeyPaths(new NSArray(
YourEO.RELATIONSHIP_NAME.dot(OtherEO.RELATIONSHIP_NAME).key()
)
);
editingContext.objectsWithFetchSpecification(fetchSpec);


NOTE: Your identity qualifier might be like so:

EOEntity entity = EOUtilities.entityForObject(yourEO.editingContext(), yourEO);
EOKeyGlobalID globalID = (EOKeyGlobalID) 
eo.editingContext().globalIDForObject(eo);
NSDictionary primaryKey = 
entity.primaryKeyForGlobalID(globalID);
EOQualifier identityQualifier = entity.qualifierForPrimaryKey(primaryKey);

profit - save yourself 100 grand. 
AARON ROSENZWEIG / Chat 'n Bike 
e:  aa...@chatnbike.com   t:  (301) 956-2319



> On Mar 5, 2018, at 2:24 PM, Chuck Hill  wrote:
> 
> Hi André,
> 
> Invalidating the GlobalIds won’t work.  That will just refresh the objects 
> that you have a list of already.  From your description, I think that you 
> want to refresh what is in list (get an updated list with inserted and 
> deleted rows that match the databse).  This should work
> ERXEOControlUtilities. clearSnapshotForRelationshipNamed(eo, " extWsProjects 
> ");
> 
> Following that you many need to refault the objects in the relationship.
> 
> 
> 
> On 2018-03-05, 8:31 AM, "Webobjects-dev on behalf of André Rothe" 
>   on behalf 
> of andre.ro...@zks.uni-leipzig.de > 
> wrote:
> 
>Hi,
> 
>I have an EO with a relationship to a second EO. The database in the
>background will be changed by another application, so it will be
>necessary to refetch the associated EOs of the relationship on every
>access.
> 
>How I can invalidate the list of the associated EOs?
> 
>This is the generated method (EOGenerator):
> 
>public NSArray extWsProjects() {
> // TODO: invalidate this array
> return (NSArray)storedValueForKey("extWsProjects");
>}
> 
>On the page
>
> https://en.wikibooks.org/wiki/WebObjects/EOF/Using_EOF/Caching_and_Freshness
> 
>I read something from Jesse Barnum, should I get all the ExtWsProject
>objects and their GIDs to call ec.invalidateObjectsWithGlobalIDs(ids) to
>make faults?
> 
>But what about deleted rows in the database, the other application can
>also delete rows, so the faults should not be necessary?
> 
>Thanks a lot
>Andre
> 
> ___
>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/chill%40gevityinc.com 
> 
> 
>This email sent to 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/aaron%40chatnbike.com 
> 
> 
> This email sent to aa...@chatnbike.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


Re: invalidate relationship cache

2018-03-05 Thread Chuck Hill
Hi André,

Invalidating the GlobalIds won’t work.  That will just refresh the objects that 
you have a list of already.  From your description, I think that you want to 
refresh what is in list (get an updated list with inserted and deleted rows 
that match the databse).  This should work
ERXEOControlUtilities. clearSnapshotForRelationshipNamed(eo, " extWsProjects ");

Following that you many need to refault the objects in the relationship.



On 2018-03-05, 8:31 AM, "Webobjects-dev on behalf of André Rothe" 
 wrote:

Hi,

I have an EO with a relationship to a second EO. The database in the
background will be changed by another application, so it will be
necessary to refetch the associated EOs of the relationship on every
access.

How I can invalidate the list of the associated EOs?

This is the generated method (EOGenerator):

public NSArray extWsProjects() {
 // TODO: invalidate this array
 return (NSArray)storedValueForKey("extWsProjects");
}

On the page
https://en.wikibooks.org/wiki/WebObjects/EOF/Using_EOF/Caching_and_Freshness

I read something from Jesse Barnum, should I get all the ExtWsProject
objects and their GIDs to call ec.invalidateObjectsWithGlobalIDs(ids) to
make faults?

But what about deleted rows in the database, the other application can
also delete rows, so the faults should not be necessary?

Thanks a lot
Andre

 ___
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/chill%40gevityinc.com

This email sent to 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/archive%40mail-archive.com

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


invalidate relationship cache

2018-03-05 Thread André Rothe
Hi,

I have an EO with a relationship to a second EO. The database in the
background will be changed by another application, so it will be
necessary to refetch the associated EOs of the relationship on every
access.

How I can invalidate the list of the associated EOs?

This is the generated method (EOGenerator):

public NSArray extWsProjects() {
 // TODO: invalidate this array
 return (NSArray)storedValueForKey("extWsProjects");
}

On the page
https://en.wikibooks.org/wiki/WebObjects/EOF/Using_EOF/Caching_and_Freshness

I read something from Jesse Barnum, should I get all the ExtWsProject
objects and their GIDs to call ec.invalidateObjectsWithGlobalIDs(ids) to
make faults?

But what about deleted rows in the database, the other application can
also delete rows, so the faults should not be necessary?

Thanks a lot
Andre

 ___
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