Re: Creating a fault for an ObjectId

2017-02-22 Thread Andrus Adamchik
Yes, the observed behavior is expected. I thought this was a question about getting a hold of an object fault (which localObject does), but this is essentially a variation of "A way to refreshObject()" topic. Let me answer in that thread. Andrus > On Feb 22, 2017, at 4:02 PM, Musall, Maik w

Re: Creating a fault for an ObjectId

2017-02-22 Thread Musall, Maik
Hi, I tested it. It will not pick up the changes made in the other context. Paraphrasing: 1. create obj1 in oc1 2. create oc2, obj2 = oc2.localObject(obj1) 3. obj2.setSomething(newValue); oc2.commitChanges() 4. obj1.something() has still old value 5. obj1 = oc1.localObject(obj1), still old value

Re: Creating a fault for an ObjectId

2017-02-21 Thread Andrus Adamchik
Since the task is to collect objects from multiple contexts in a single resulting context, you may use this: context.localObject(objectFromAnotherContext) (I don't think anyone has mentioned "localObject" in this thread ??) Andrus > On Feb 15, 2017, at 7:17 PM, Musall, Maik wrote: > > Th

Re: Creating a fault for an ObjectId

2017-02-15 Thread Musall, Maik
Hi Michael, that's an interesting idea, thank you. That could work. I'll think about it. Maik > Am 15.02.2017 um 16:31 schrieb Michael Gentry : > > Hi Maik, > > Would it be possible to use child DataContexts and then push the changes up > to the parent? > > > On Wed, Feb 15, 2017 at 11:17 A

Re: Creating a fault for an ObjectId

2017-02-15 Thread Michael Gentry
Hi Maik, Would it be possible to use child DataContexts and then push the changes up to the parent? On Wed, Feb 15, 2017 at 11:17 AM, Musall, Maik wrote: > The use case is as follows. > > I have a large collection of objects which I want some function to be > executed on. I want to use multipl

Re: Creating a fault for an ObjectId

2017-02-15 Thread Amedeo Mantica
I'm a WebObject/EOF guy too :-) the idea of use nested context is not bad, you can revert the object in the nested context one and it will get cached values from parent Amedeo > On 15 Feb 2017, at 17:31, Michael Gentry wrote: > > Hi Maik, > > Would it be possible to use child DataContexts an

Re: Creating a fault for an ObjectId

2017-02-15 Thread Musall, Maik
The use case is as follows. I have a large collection of objects which I want some function to be executed on. I want to use multiple threads to do this, so AFAIK I have to use separate ObjectContexts per thread like in EOF. So, I will then instantiate those objects in the per-thread contexts,

Re: Creating a fault for an ObjectId

2017-02-15 Thread Ken Anderson
Yes, use the objectID to pass around, but on the receiving end, you should turn it into a fault and release it into the wild. Then, if some code needs it, the fault fires, otherwise – no DB activity. Ken Anderson CTO Amphora, Inc. Mobile: +1 914 262 8540 www.amphorainc.com

Re: Creating a fault for an ObjectId

2017-02-15 Thread Amedeo Mantica
I would just use the ObjectId > On 15 Feb 2017, at 16:45, Hugi Thordarson wrote: > > It can be useful in some cases—one example is if you want to be able to pass > objects around in an API without triggering a DB fetch unless they are > actually used. > > Cheers, > - hugi > > >> On 15. feb.

Re: Creating a fault for an ObjectId

2017-02-15 Thread Ken Anderson
I could certainly use this too! You would think it would be easy… Ken Anderson CTO Amphora, Inc. Mobile: +1 914 262 8540 www.amphorainc.com On 2/15/17, 10:45 AM, "Hugi Thordarson" wrote: It can be useful in some cases—one example is if you want to be ab

Re: Creating a fault for an ObjectId

2017-02-15 Thread Hugi Thordarson
It can be useful in some cases—one example is if you want to be able to pass objects around in an API without triggering a DB fetch unless they are actually used. Cheers, - hugi > On 15. feb. 2017, at 15:28, Amedeo Mantica wrote: > > no worries, but I cannot understand your goal, why do you

Re: Creating a fault for an ObjectId

2017-02-15 Thread Hugi Thordarson
Thanks Ken, but the immediate fetch performed by Cayenne.objectForPk is precisely what I’d like to avoid. Cheers, - hugi S: Amedeo, sorry about calling you “Amadeo” in my last post. I have been properly lambasted. > On 15. feb. 2017, at 15:20, Ken Anderson wrote: > > I do this: > > dataObj

Re: Creating a fault for an ObjectId

2017-02-15 Thread Amedeo Mantica
no worries, but I cannot understand your goal, why do you want to get the fault ? > On 15 Feb 2017, at 16:25, Hugi Thordarson wrote: > > Thanks Ken, but the immediate fetch performed by Cayenne.objectForPk is > precisely what I’d like to avoid. > > Cheers, > - hugi > > S: Amedeo, sorry about

Re: Creating a fault for an ObjectId

2017-02-15 Thread Ken Anderson
I do this: dataObject = (DataObject) Cayenne.objectForPK(getObjectContext(), MyEntity.class, oid); But it will do the fetch if it’s not already in cache. Ken Ken Anderson CTO Amphora, Inc. Mobile: +1 914 262 8540 www.amphorainc.com On 2/15/17, 9:59 AM, "Hu

Re: Creating a fault for an ObjectId

2017-02-15 Thread Hugi Thordarson
Thanks Amadeo, but I ended up creating a method that looks like this. It would be nice to get some feedback on it, if I’m violating any Cayenne Commandments. /** * @return An existing object or fault if registered with the OC, otherwise creates a new hollow object based on the g

Re: Creating a fault for an ObjectId

2017-02-15 Thread Amedeo Mantica
may be you want invalidateObject ? > On 15 Feb 2017, at 14:15, Hugi Thordarson wrote: > > Hi all, > I need to get a fault for an ObjectId from an ObjectContext. How would I do > this? > > I don’t see any public API for this—the implementation of createFault in > CayenneContext seems to get me

Creating a fault for an ObjectId

2017-02-15 Thread Hugi Thordarson
Hi all, I need to get a fault for an ObjectId from an ObjectContext. How would I do this? I don’t see any public API for this—the implementation of createFault in CayenneContext seems to get me halfway there, but it will not return an existing fault, only create new ones. Cheers, - hugi