Re: A way to refreshObject()

2017-02-22 Thread Andrus Adamchik
> On Feb 22, 2017, at 10:42 PM, Musall, Maik wrote: > >> IIRC this also whacks to-many relationships, and those require a query to >> get restored, as we can't guess relationship composition (another reason >> why I gave up on managing graph refreshing in memory). > > I did test adding a new

Re: A way to refreshObject()

2017-02-22 Thread Musall, Maik
> Am 22.02.2017 um 19:39 schrieb Andrus Adamchik : > > >> On Feb 22, 2017, at 6:55 PM, Musall, Maik wrote: >> >> Hi Andrus, >> >> ok, setting PersistenceState.HOLLOW works. So easy :-) > > Ah great. We all just learned a new Cayenne trick :) > > IIRC this also whacks to-many relationships,

Re: A way to refreshObject()

2017-02-22 Thread Andrus Adamchik
> On Feb 22, 2017, at 6:55 PM, Musall, Maik wrote: > > Hi Andrus, > > ok, setting PersistenceState.HOLLOW works. So easy :-) Ah great. We all just learned a new Cayenne trick :) IIRC this also whacks to-many relationships, and those require a query to get restored, as we can't guess relatio

Re: A way to refreshObject()

2017-02-22 Thread Musall, Maik
Hi Andrus, ok, setting PersistenceState.HOLLOW works. So easy :-) I'm subscribing to your argument to generally refreshing entire collections for consistency. But this isn't about a simple CMS with a few blog posts. I have cases where I have spent considerable resources to fetch large object gr

Re: A way to refreshObject()

2017-02-22 Thread Andrus Adamchik
> On Feb 22, 2017, at 4:33 PM, Andrus Adamchik wrote: > oc1.refreshObject(obj), or even oc1.refreshAllObjects() BTW, the following should probably work: object.setPersistenceState(PersistenceState.HOLLOW); As odd as it sounds, I've never tried doing it myself. But looking at the code, i

Re: A way to refreshObject()

2017-02-22 Thread Andrus Adamchik
Hi Maik, Like I said, I personally hate chasing individual object changes, and rather deal with refreshing entire collections. Refreshing individual objects quickly leads to cases that are nearly impossible to handle in the code, as modified objects may no longer match the criteria for being in

Re: A way to refreshObject()

2017-02-22 Thread Musall, Maik
Hi Andrus, this works, but requires using the newly localObject()ed object instance to be used after refreshing. Any other references of that object in the original context will still hold the unchanged values. Btw, I found the page I mentioned: https://cayenne.apache.org/docs/4.0/cayenne-guid

Re: A way to refreshObject()

2017-02-21 Thread Andrus Adamchik
Since we mostly focused on policy- and event-based *query* caches, the API for managing caching of individual objects is not as streamlined, but here it is FWIW: T myObject = ..; ObjectContext context = myObject.getObjectContext(); ObjectId id = myObject.getObjectId(); // kick it out, unset Obj

A way to refreshObject()

2017-02-21 Thread Musall, Maik
Hi all, I have an application using a big shared snapshot cache. Objects freshly instantiated in an ObjectContext get their attributes populated based on the snapshot cache at the time, and keep them during the context's lifetime, which is also what I want. (Last week I found a page on cayenne.