Creating a fault for an ObjectId

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating a fault for an ObjectId

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
Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

Amedeo Mantica
may be you want invalidateObject ?

> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>
> Cheers,
> - hugi

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 given ObjectId.
         */
        public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
                Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
               
                if( object == null ) {
                        ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());

                        object = (Persistent) descriptor.createObject();
                       
                        object.setPersistenceState(PersistenceState.HOLLOW);
                        object.setObjectContext(oc);
                        object.setObjectId(objectId);
                       
                        oc.getGraphManager().registerNode(objectId, object);
                }

                return object;
        }

Cheers,
- hugi


> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
>
> may be you want invalidateObject ?
>
>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>>
>> Cheers,
>> - hugi
>

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 <http://www.amphorainc.com/>




On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:

    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 given ObjectId.
     */
    public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
    Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );

    if( object == null ) {
    ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());

    object = (Persistent) descriptor.createObject();

    object.setPersistenceState(PersistenceState.HOLLOW);
    object.setObjectContext(oc);
    object.setObjectId(objectId);

    oc.getGraphManager().registerNode(objectId, object);
    }

    return object;
    }

    Cheers,
    - hugi


    > On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
    >
    > may be you want invalidateObject ?
    >
    >> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
    >>
    >> Cheers,
    >> - hugi
    >



Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 <[hidden email]> wrote:
>
> 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 <http://www.amphorainc.com/>
>
>
>
>
> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>
>    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 given ObjectId.
>     */
>    public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
>    Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
>
>    if( object == null ) {
>    ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
>
>    object = (Persistent) descriptor.createObject();
>
>    object.setPersistenceState(PersistenceState.HOLLOW);
>    object.setObjectContext(oc);
>    object.setObjectId(objectId);
>
>    oc.getGraphManager().registerNode(objectId, object);
>    }
>
>    return object;
>    }
>
>    Cheers,
>    - hugi
>
>
>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
>>
>> may be you want invalidateObject ?
>>
>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>>>
>>> Cheers,
>>> - hugi
>>
>
>
>
> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have been properly lambasted.
>
>
>> On 15. feb. 2017, at 15:20, Ken Anderson <[hidden email]> wrote:
>>
>> 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 <http://www.amphorainc.com/>
>>
>>
>>
>>
>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>>
>>   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 given ObjectId.
>>    */
>>   public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
>>   Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
>>
>>   if( object == null ) {
>>   ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
>>
>>   object = (Persistent) descriptor.createObject();
>>
>>   object.setPersistenceState(PersistenceState.HOLLOW);
>>   object.setObjectContext(oc);
>>   object.setObjectId(objectId);
>>
>>   oc.getGraphManager().registerNode(objectId, object);
>>   }
>>
>>   return object;
>>   }
>>
>>   Cheers,
>>   - hugi
>>
>>
>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
>>>
>>> may be you want invalidateObject ?
>>>
>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>>>>
>>>> Cheers,
>>>> - hugi
>>>
>>
>>
>>
>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 <[hidden email]> wrote:
>
> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have been properly lambasted.
>>
>>
>>> On 15. feb. 2017, at 15:20, Ken Anderson <[hidden email]> wrote:
>>>
>>> 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 <http://www.amphorainc.com/>
>>>
>>>
>>>
>>>
>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>>>
>>>  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 given ObjectId.
>>>   */
>>>  public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
>>>  Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
>>>
>>>  if( object == null ) {
>>>  ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
>>>
>>>  object = (Persistent) descriptor.createObject();
>>>
>>>  object.setPersistenceState(PersistenceState.HOLLOW);
>>>  object.setObjectContext(oc);
>>>  object.setObjectId(objectId);
>>>
>>>  oc.getGraphManager().registerNode(objectId, object);
>>>  }
>>>
>>>  return object;
>>>  }
>>>
>>>  Cheers,
>>>  - hugi
>>>
>>>
>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
>>>>
>>>> may be you want invalidateObject ?
>>>>
>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>>>>>
>>>>> Cheers,
>>>>> - hugi
>>>>
>>>
>>>
>>>
>>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 <http://www.amphorainc.com/>




On 2/15/17, 10:45 AM, "Hugi Thordarson" <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]> wrote:
    >
    > 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have been properly lambasted.
    >>
    >>
    >>> On 15. feb. 2017, at 15:20, Ken Anderson <[hidden email]> wrote:
    >>>
    >>> 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 <http://www.amphorainc.com/>
    >>>
    >>>
    >>>
    >>>
    >>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
    >>>
    >>>  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 given ObjectId.
    >>>   */
    >>>  public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
    >>>  Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
    >>>
    >>>  if( object == null ) {
    >>>  ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
    >>>
    >>>  object = (Persistent) descriptor.createObject();
    >>>
    >>>  object.setPersistenceState(PersistenceState.HOLLOW);
    >>>  object.setObjectContext(oc);
    >>>  object.setObjectId(objectId);
    >>>
    >>>  oc.getGraphManager().registerNode(objectId, object);
    >>>  }
    >>>
    >>>  return object;
    >>>  }
    >>>
    >>>  Cheers,
    >>>  - hugi
    >>>
    >>>
    >>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
    >>>>
    >>>> may be you want invalidateObject ?
    >>>>
    >>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
    >>>>>
    >>>>> Cheers,
    >>>>> - hugi
    >>>>
    >>>
    >>>
    >>>
    >>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
    >>
    >



Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

Amedeo Mantica
In reply to this post by Hugi Thordarson
I would just use the ObjectId

> On 15 Feb 2017, at 16:45, Hugi Thordarson <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]> wrote:
>>
>> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have been properly lambasted.
>>>
>>>
>>>> On 15. feb. 2017, at 15:20, Ken Anderson <[hidden email]> wrote:
>>>>
>>>> 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 <http://www.amphorainc.com/>
>>>>
>>>>
>>>>
>>>>
>>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>>>>
>>>> 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 given ObjectId.
>>>>  */
>>>> public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
>>>> Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
>>>>
>>>> if( object == null ) {
>>>> ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
>>>>
>>>> object = (Persistent) descriptor.createObject();
>>>>
>>>> object.setPersistenceState(PersistenceState.HOLLOW);
>>>> object.setObjectContext(oc);
>>>> object.setObjectId(objectId);
>>>>
>>>> oc.getGraphManager().registerNode(objectId, object);
>>>> }
>>>>
>>>> return object;
>>>> }
>>>>
>>>> Cheers,
>>>> - hugi
>>>>
>>>>
>>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
>>>>>
>>>>> may be you want invalidateObject ?
>>>>>
>>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>>>>>>
>>>>>> Cheers,
>>>>>> - hugi
>>>>>
>>>>
>>>>
>>>>
>>>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 <http://www.amphorainc.com/>




On 2/15/17, 10:47 AM, "Amedeo Mantica" <[hidden email]> wrote:

    I would just use the ObjectId

    > On 15 Feb 2017, at 16:45, Hugi Thordarson <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]> wrote:
    >>
    >> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have been properly lambasted.
    >>>
    >>>
    >>>> On 15. feb. 2017, at 15:20, Ken Anderson <[hidden email]> wrote:
    >>>>
    >>>> 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 <http://www.amphorainc.com/>
    >>>>
    >>>>
    >>>>
    >>>>
    >>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
    >>>>
    >>>> 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 given ObjectId.
    >>>>  */
    >>>> public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
    >>>> Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
    >>>>
    >>>> if( object == null ) {
    >>>> ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
    >>>>
    >>>> object = (Persistent) descriptor.createObject();
    >>>>
    >>>> object.setPersistenceState(PersistenceState.HOLLOW);
    >>>> object.setObjectContext(oc);
    >>>> object.setObjectId(objectId);
    >>>>
    >>>> oc.getGraphManager().registerNode(objectId, object);
    >>>> }
    >>>>
    >>>> return object;
    >>>> }
    >>>>
    >>>> Cheers,
    >>>> - hugi
    >>>>
    >>>>
    >>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
    >>>>>
    >>>>> may be you want invalidateObject ?
    >>>>>
    >>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
    >>>>>>
    >>>>>> Cheers,
    >>>>>> - hugi
    >>>>>
    >>>>
    >>>>
    >>>>
    >>>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
    >>>
    >>
    >



Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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, do the processing, but then the wrapper function should return the entire collection of processed objects in the original context that they were in at the beginning.

With EOF, I have a snapshot cache that will contain the changed attributes, but the EO instances in the original context have their original values. So, I will then call ec.faultForGlobalID() to have them refaulted from the snapshot cache, avoiding to refetch 100.000 objects from db.

I suppose using a shared cache would make the problem obsolete, as those objects would receive changed attributes automatically, but I'm still on the fence whether or not to use a shared cache, because it's a major behavioural difference to EOF and I still have to think about that while migrating my project.

Maik


> Am 15.02.2017 um 15:49 schrieb Ken Anderson <[hidden email]>:
>
> 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 <http://www.amphorainc.com/>
>
>
>
>
> On 2/15/17, 10:47 AM, "Amedeo Mantica" <[hidden email]> wrote:
>
>    I would just use the ObjectId
>
>> On 15 Feb 2017, at 16:45, Hugi Thordarson <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]> wrote:
>>>
>>> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have been properly lambasted.
>>>>
>>>>
>>>>> On 15. feb. 2017, at 15:20, Ken Anderson <[hidden email]> wrote:
>>>>>
>>>>> 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 <http://www.amphorainc.com/>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>>>>>
>>>>> 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 given ObjectId.
>>>>> */
>>>>> public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
>>>>> Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
>>>>>
>>>>> if( object == null ) {
>>>>> ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
>>>>>
>>>>> object = (Persistent) descriptor.createObject();
>>>>>
>>>>> object.setPersistenceState(PersistenceState.HOLLOW);
>>>>> object.setObjectContext(oc);
>>>>> object.setObjectId(objectId);
>>>>>
>>>>> oc.getGraphManager().registerNode(objectId, object);
>>>>> }
>>>>>
>>>>> return object;
>>>>> }
>>>>>
>>>>> Cheers,
>>>>> - hugi
>>>>>
>>>>>
>>>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
>>>>>>
>>>>>> may be you want invalidateObject ?
>>>>>>
>>>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>>>>>>>
>>>>>>> Cheers,
>>>>>>> - hugi
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>>>>
>>>
>>
>
>
>
> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 <[hidden email]> 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 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, do the processing,
> but then the wrapper function should return the entire collection of
> processed objects in the original context that they were in at the
> beginning.
>
> With EOF, I have a snapshot cache that will contain the changed
> attributes, but the EO instances in the original context have their
> original values. So, I will then call ec.faultForGlobalID() to have them
> refaulted from the snapshot cache, avoiding to refetch 100.000 objects from
> db.
>
> I suppose using a shared cache would make the problem obsolete, as those
> objects would receive changed attributes automatically, but I'm still on
> the fence whether or not to use a shared cache, because it's a major
> behavioural difference to EOF and I still have to think about that while
> migrating my project.
>
> Maik
>
>
> > Am 15.02.2017 um 15:49 schrieb Ken Anderson <[hidden email]
> >:
> >
> > 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 <http://www.amphorainc.com/>
> >
> >
> >
> >
> > On 2/15/17, 10:47 AM, "Amedeo Mantica" <[hidden email]> wrote:
> >
> >    I would just use the ObjectId
> >
> >> On 15 Feb 2017, at 16:45, Hugi Thordarson <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]>
> wrote:
> >>>
> >>> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have
> been properly lambasted.
> >>>>
> >>>>
> >>>>> On 15. feb. 2017, at 15:20, Ken Anderson <
> [hidden email]> wrote:
> >>>>>
> >>>>> 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 <http://www.amphorainc.com/>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
> >>>>>
> >>>>> 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 given ObjectId.
> >>>>> */
> >>>>> public static Persistent faultForObjectId( ObjectContext oc,
> ObjectId objectId ) {
> >>>>> Persistent object = (Persistent) oc.getGraphManager().getNode(
> objectId );
> >>>>>
> >>>>> if( object == null ) {
> >>>>> ClassDescriptor descriptor = oc.getEntityResolver().
> getClassDescriptor(objectId.getEntityName());
> >>>>>
> >>>>> object = (Persistent) descriptor.createObject();
> >>>>>
> >>>>> object.setPersistenceState(PersistenceState.HOLLOW);
> >>>>> object.setObjectContext(oc);
> >>>>> object.setObjectId(objectId);
> >>>>>
> >>>>> oc.getGraphManager().registerNode(objectId, object);
> >>>>> }
> >>>>>
> >>>>> return object;
> >>>>> }
> >>>>>
> >>>>> Cheers,
> >>>>> - hugi
> >>>>>
> >>>>>
> >>>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]>
> wrote:
> >>>>>>
> >>>>>> may be you want invalidateObject ?
> >>>>>>
> >>>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]>
> 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 halfway there, but it will
> not return an existing fault, only create new ones.
> >>>>>>>
> >>>>>>> Cheers,
> >>>>>>> - hugi
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> Confidentiality Notice: This e-mail and accompanying documents
> contain confidential information intended for a specific individual and
> purpose. This e-mailed information is private and protected by law. If you
> are not the intended recipient, you are hereby notified that any
> disclosure, copying, or distribution, or the taking of any action based on
> the contents of this information, is strictly prohibited.
> >>>>
> >>>
> >>
> >
> >
> >
> > Confidentiality Notice: This e-mail and accompanying documents contain
> confidential information intended for a specific individual and purpose.
> This e-mailed information is private and protected by law. If you are not
> the intended recipient, you are hereby notified that any disclosure,
> copying, or distribution, or the taking of any action based on the contents
> of this information, is strictly prohibited.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 <[hidden email]> wrote:
>
> 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 <[hidden email]> 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 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, do the processing,
>> but then the wrapper function should return the entire collection of
>> processed objects in the original context that they were in at the
>> beginning.
>>
>> With EOF, I have a snapshot cache that will contain the changed
>> attributes, but the EO instances in the original context have their
>> original values. So, I will then call ec.faultForGlobalID() to have them
>> refaulted from the snapshot cache, avoiding to refetch 100.000 objects from
>> db.
>>
>> I suppose using a shared cache would make the problem obsolete, as those
>> objects would receive changed attributes automatically, but I'm still on
>> the fence whether or not to use a shared cache, because it's a major
>> behavioural difference to EOF and I still have to think about that while
>> migrating my project.
>>
>> Maik
>>
>>
>>> Am 15.02.2017 um 15:49 schrieb Ken Anderson <[hidden email]
>>> :
>>>
>>> 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 <http://www.amphorainc.com/>
>>>
>>>
>>>
>>>
>>> On 2/15/17, 10:47 AM, "Amedeo Mantica" <[hidden email]> wrote:
>>>
>>>   I would just use the ObjectId
>>>
>>>> On 15 Feb 2017, at 16:45, Hugi Thordarson <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]>
>> wrote:
>>>>>
>>>>> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have
>> been properly lambasted.
>>>>>>
>>>>>>
>>>>>>> On 15. feb. 2017, at 15:20, Ken Anderson <
>> [hidden email]> wrote:
>>>>>>>
>>>>>>> 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 <http://www.amphorainc.com/>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>>>>>>>
>>>>>>> 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 given ObjectId.
>>>>>>> */
>>>>>>> public static Persistent faultForObjectId( ObjectContext oc,
>> ObjectId objectId ) {
>>>>>>> Persistent object = (Persistent) oc.getGraphManager().getNode(
>> objectId );
>>>>>>>
>>>>>>> if( object == null ) {
>>>>>>> ClassDescriptor descriptor = oc.getEntityResolver().
>> getClassDescriptor(objectId.getEntityName());
>>>>>>>
>>>>>>> object = (Persistent) descriptor.createObject();
>>>>>>>
>>>>>>> object.setPersistenceState(PersistenceState.HOLLOW);
>>>>>>> object.setObjectContext(oc);
>>>>>>> object.setObjectId(objectId);
>>>>>>>
>>>>>>> oc.getGraphManager().registerNode(objectId, object);
>>>>>>> }
>>>>>>>
>>>>>>> return object;
>>>>>>> }
>>>>>>>
>>>>>>> Cheers,
>>>>>>> - hugi
>>>>>>>
>>>>>>>
>>>>>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]>
>> wrote:
>>>>>>>>
>>>>>>>> may be you want invalidateObject ?
>>>>>>>>
>>>>>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]>
>> 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 halfway there, but it will
>> not return an existing fault, only create new ones.
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> - hugi
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Confidentiality Notice: This e-mail and accompanying documents
>> contain confidential information intended for a specific individual and
>> purpose. This e-mailed information is private and protected by law. If you
>> are not the intended recipient, you are hereby notified that any
>> disclosure, copying, or distribution, or the taking of any action based on
>> the contents of this information, is strictly prohibited.
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> Confidentiality Notice: This e-mail and accompanying documents contain
>> confidential information intended for a specific individual and purpose.
>> This e-mailed information is private and protected by law. If you are not
>> the intended recipient, you are hereby notified that any disclosure,
>> copying, or distribution, or the taking of any action based on the contents
>> of this information, is strictly prohibited.
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

Musall, Maik
In reply to this post by Michael Gentry
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 <[hidden email]>:
>
> 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 <[hidden email]> 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 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, do the processing,
>> but then the wrapper function should return the entire collection of
>> processed objects in the original context that they were in at the
>> beginning.
>>
>> With EOF, I have a snapshot cache that will contain the changed
>> attributes, but the EO instances in the original context have their
>> original values. So, I will then call ec.faultForGlobalID() to have them
>> refaulted from the snapshot cache, avoiding to refetch 100.000 objects from
>> db.
>>
>> I suppose using a shared cache would make the problem obsolete, as those
>> objects would receive changed attributes automatically, but I'm still on
>> the fence whether or not to use a shared cache, because it's a major
>> behavioural difference to EOF and I still have to think about that while
>> migrating my project.
>>
>> Maik
>>
>>
>>> Am 15.02.2017 um 15:49 schrieb Ken Anderson <[hidden email]
>>> :
>>>
>>> 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 <http://www.amphorainc.com/>
>>>
>>>
>>>
>>>
>>> On 2/15/17, 10:47 AM, "Amedeo Mantica" <[hidden email]> wrote:
>>>
>>>   I would just use the ObjectId
>>>
>>>> On 15 Feb 2017, at 16:45, Hugi Thordarson <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]>
>> wrote:
>>>>>
>>>>> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have
>> been properly lambasted.
>>>>>>
>>>>>>
>>>>>>> On 15. feb. 2017, at 15:20, Ken Anderson <
>> [hidden email]> wrote:
>>>>>>>
>>>>>>> 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 <http://www.amphorainc.com/>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>>>>>>>
>>>>>>> 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 given ObjectId.
>>>>>>> */
>>>>>>> public static Persistent faultForObjectId( ObjectContext oc,
>> ObjectId objectId ) {
>>>>>>> Persistent object = (Persistent) oc.getGraphManager().getNode(
>> objectId );
>>>>>>>
>>>>>>> if( object == null ) {
>>>>>>> ClassDescriptor descriptor = oc.getEntityResolver().
>> getClassDescriptor(objectId.getEntityName());
>>>>>>>
>>>>>>> object = (Persistent) descriptor.createObject();
>>>>>>>
>>>>>>> object.setPersistenceState(PersistenceState.HOLLOW);
>>>>>>> object.setObjectContext(oc);
>>>>>>> object.setObjectId(objectId);
>>>>>>>
>>>>>>> oc.getGraphManager().registerNode(objectId, object);
>>>>>>> }
>>>>>>>
>>>>>>> return object;
>>>>>>> }
>>>>>>>
>>>>>>> Cheers,
>>>>>>> - hugi
>>>>>>>
>>>>>>>
>>>>>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]>
>> wrote:
>>>>>>>>
>>>>>>>> may be you want invalidateObject ?
>>>>>>>>
>>>>>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]>
>> 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 halfway there, but it will
>> not return an existing fault, only create new ones.
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> - hugi
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Confidentiality Notice: This e-mail and accompanying documents
>> contain confidential information intended for a specific individual and
>> purpose. This e-mailed information is private and protected by law. If you
>> are not the intended recipient, you are hereby notified that any
>> disclosure, copying, or distribution, or the taking of any action based on
>> the contents of this information, is strictly prohibited.
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> Confidentiality Notice: This e-mail and accompanying documents contain
>> confidential information intended for a specific individual and purpose.
>> This e-mailed information is private and protected by law. If you are not
>> the intended recipient, you are hereby notified that any disclosure,
>> copying, or distribution, or the taking of any action based on the contents
>> of this information, is strictly prohibited.
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

Andrus Adamchik
In reply to this post by Musall, Maik
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 <[hidden email]> 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 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, do the processing, but then the wrapper function should return the entire collection of processed objects in the original context that they were in at the beginning.
>
> With EOF, I have a snapshot cache that will contain the changed attributes, but the EO instances in the original context have their original values. So, I will then call ec.faultForGlobalID() to have them refaulted from the snapshot cache, avoiding to refetch 100.000 objects from db.
>
> I suppose using a shared cache would make the problem obsolete, as those objects would receive changed attributes automatically, but I'm still on the fence whether or not to use a shared cache, because it's a major behavioural difference to EOF and I still have to think about that while migrating my project.
>
> Maik
>
>
>> Am 15.02.2017 um 15:49 schrieb Ken Anderson <[hidden email]>:
>>
>> 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 <http://www.amphorainc.com/>
>>
>>
>>
>>
>> On 2/15/17, 10:47 AM, "Amedeo Mantica" <[hidden email]> wrote:
>>
>>   I would just use the ObjectId
>>
>>> On 15 Feb 2017, at 16:45, Hugi Thordarson <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]> wrote:
>>>>
>>>> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have been properly lambasted.
>>>>>
>>>>>
>>>>>> On 15. feb. 2017, at 15:20, Ken Anderson <[hidden email]> wrote:
>>>>>>
>>>>>> 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 <http://www.amphorainc.com/>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>>>>>>
>>>>>> 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 given ObjectId.
>>>>>> */
>>>>>> public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
>>>>>> Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
>>>>>>
>>>>>> if( object == null ) {
>>>>>> ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
>>>>>>
>>>>>> object = (Persistent) descriptor.createObject();
>>>>>>
>>>>>> object.setPersistenceState(PersistenceState.HOLLOW);
>>>>>> object.setObjectContext(oc);
>>>>>> object.setObjectId(objectId);
>>>>>>
>>>>>> oc.getGraphManager().registerNode(objectId, object);
>>>>>> }
>>>>>>
>>>>>> return object;
>>>>>> }
>>>>>>
>>>>>> Cheers,
>>>>>> - hugi
>>>>>>
>>>>>>
>>>>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
>>>>>>>
>>>>>>> may be you want invalidateObject ?
>>>>>>>
>>>>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> - hugi
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>>>>>
>>>>
>>>
>>
>>
>>
>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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
6. obj1 = oc1.localObject(obj2), still old value

Only when you create a new oc3 and localObject() in that, you will see the changed value. Btw, I have this set:
binder.bindMap(Constants.PROPERTIES_MAP).put(Constants.SERVER_CONTEXTS_SYNC_PROPERTY, "false");

Using child contexts may be an option, but then the saves wouldn't hit the database until I commit again in the parent context, which in my case the processing routine has no business in.

Maik



> Am 22.02.2017 um 07:17 schrieb Andrus Adamchik <[hidden email]>:
>
> 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 <[hidden email]> 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 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, do the processing, but then the wrapper function should return the entire collection of processed objects in the original context that they were in at the beginning.
>>
>> With EOF, I have a snapshot cache that will contain the changed attributes, but the EO instances in the original context have their original values. So, I will then call ec.faultForGlobalID() to have them refaulted from the snapshot cache, avoiding to refetch 100.000 objects from db.
>>
>> I suppose using a shared cache would make the problem obsolete, as those objects would receive changed attributes automatically, but I'm still on the fence whether or not to use a shared cache, because it's a major behavioural difference to EOF and I still have to think about that while migrating my project.
>>
>> Maik
>>
>>
>>> Am 15.02.2017 um 15:49 schrieb Ken Anderson <[hidden email]>:
>>>
>>> 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 <http://www.amphorainc.com/>
>>>
>>>
>>>
>>>
>>> On 2/15/17, 10:47 AM, "Amedeo Mantica" <[hidden email]> wrote:
>>>
>>>  I would just use the ObjectId
>>>
>>>> On 15 Feb 2017, at 16:45, Hugi Thordarson <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]> wrote:
>>>>>
>>>>> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have been properly lambasted.
>>>>>>
>>>>>>
>>>>>>> On 15. feb. 2017, at 15:20, Ken Anderson <[hidden email]> wrote:
>>>>>>>
>>>>>>> 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 <http://www.amphorainc.com/>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>>>>>>>
>>>>>>> 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 given ObjectId.
>>>>>>> */
>>>>>>> public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
>>>>>>> Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
>>>>>>>
>>>>>>> if( object == null ) {
>>>>>>> ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
>>>>>>>
>>>>>>> object = (Persistent) descriptor.createObject();
>>>>>>>
>>>>>>> object.setPersistenceState(PersistenceState.HOLLOW);
>>>>>>> object.setObjectContext(oc);
>>>>>>> object.setObjectId(objectId);
>>>>>>>
>>>>>>> oc.getGraphManager().registerNode(objectId, object);
>>>>>>> }
>>>>>>>
>>>>>>> return object;
>>>>>>> }
>>>>>>>
>>>>>>> Cheers,
>>>>>>> - hugi
>>>>>>>
>>>>>>>
>>>>>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> may be you want invalidateObject ?
>>>>>>>>
>>>>>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> - hugi
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Creating a fault for an ObjectId

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 <[hidden email]> wrote:
>
> 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
> 6. obj1 = oc1.localObject(obj2), still old value
>
> Only when you create a new oc3 and localObject() in that, you will see the changed value. Btw, I have this set:
> binder.bindMap(Constants.PROPERTIES_MAP).put(Constants.SERVER_CONTEXTS_SYNC_PROPERTY, "false");
>
> Using child contexts may be an option, but then the saves wouldn't hit the database until I commit again in the parent context, which in my case the processing routine has no business in.
>
> Maik
>
>
>
>> Am 22.02.2017 um 07:17 schrieb Andrus Adamchik <[hidden email]>:
>>
>> 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 <[hidden email]> 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 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, do the processing, but then the wrapper function should return the entire collection of processed objects in the original context that they were in at the beginning.
>>>
>>> With EOF, I have a snapshot cache that will contain the changed attributes, but the EO instances in the original context have their original values. So, I will then call ec.faultForGlobalID() to have them refaulted from the snapshot cache, avoiding to refetch 100.000 objects from db.
>>>
>>> I suppose using a shared cache would make the problem obsolete, as those objects would receive changed attributes automatically, but I'm still on the fence whether or not to use a shared cache, because it's a major behavioural difference to EOF and I still have to think about that while migrating my project.
>>>
>>> Maik
>>>
>>>
>>>> Am 15.02.2017 um 15:49 schrieb Ken Anderson <[hidden email]>:
>>>>
>>>> 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 <http://www.amphorainc.com/>
>>>>
>>>>
>>>>
>>>>
>>>> On 2/15/17, 10:47 AM, "Amedeo Mantica" <[hidden email]> wrote:
>>>>
>>>> I would just use the ObjectId
>>>>
>>>>> On 15 Feb 2017, at 16:45, Hugi Thordarson <[hidden email]> 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. 2017, at 15:28, Amedeo Mantica <[hidden email]> wrote:
>>>>>>
>>>>>> 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 <[hidden email]> 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 calling you “Amadeo” in my last post. I have been properly lambasted.
>>>>>>>
>>>>>>>
>>>>>>>> On 15. feb. 2017, at 15:20, Ken Anderson <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> 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 <http://www.amphorainc.com/>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> 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 given ObjectId.
>>>>>>>> */
>>>>>>>> public static Persistent faultForObjectId( ObjectContext oc, ObjectId objectId ) {
>>>>>>>> Persistent object = (Persistent) oc.getGraphManager().getNode( objectId );
>>>>>>>>
>>>>>>>> if( object == null ) {
>>>>>>>> ClassDescriptor descriptor = oc.getEntityResolver().getClassDescriptor(objectId.getEntityName());
>>>>>>>>
>>>>>>>> object = (Persistent) descriptor.createObject();
>>>>>>>>
>>>>>>>> object.setPersistenceState(PersistenceState.HOLLOW);
>>>>>>>> object.setObjectContext(oc);
>>>>>>>> object.setObjectId(objectId);
>>>>>>>>
>>>>>>>> oc.getGraphManager().registerNode(objectId, object);
>>>>>>>> }
>>>>>>>>
>>>>>>>> return object;
>>>>>>>> }
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> - hugi
>>>>>>>>
>>>>>>>>
>>>>>>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica <[hidden email]> wrote:
>>>>>>>>>
>>>>>>>>> may be you want invalidateObject ?
>>>>>>>>>
>>>>>>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson <[hidden email]> 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 halfway there, but it will not return an existing fault, only create new ones.
>>>>>>>>>>
>>>>>>>>>> Cheers,
>>>>>>>>>> - hugi
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.
>>>
>>
>