You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Frank Herrmann <fr...@modernizingmedicine.com> on 2016/05/18 13:31:37 UTC

Object Cache and Child Objects - Cayenne 3.1

Hello all,

I have a question and an observation. While reading some of the Cayenne
code, we've noticed reference to a snapshot cache. Is this the object
cache, or something different?

The issue we are seeing has to do with cayenne objects that are
parents/children of other cayenne objects. For instance, we have a User
object, we also have Staff and Patient objects that are children of the
User object.

What we have seen is that if a developer does a query for a User object by
id, the object is retrieved. Cayenne sees that this object is a Staff
object and then stores it in the object cache as a Staff object. The next
time the user goes to retrieve the User object (by the same id), Cayenne
does another call to the database, because it cannot find the User object
in the cache (because it stored it as a Staff object).

Thanks again for the help.

-Frank

-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrmann@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>

Re: Object Cache and Child Objects - Cayenne 3.1

Posted by Frank Herrmann <fr...@modernizingmedicine.com>.
Thanks for the quick response. :)

On Thu, May 19, 2016 at 6:19 AM, Andrus Adamchik <an...@objectstyle.org>
wrote:

> Just committed a fix to 3.1 and 4.0 branches:
> https://issues.apache.org/jira/browse/CAY-2084
>
>
> > On May 18, 2016, at 5:27 PM, Frank Herrmann <
> frank.herrmann@modernizingmedicine.com> wrote:
> >
> > Thanks.
> >
> > On Wed, May 18, 2016 at 10:25 AM, Andrus Adamchik <
> andrus@objectstyle.org>
> > wrote:
> >
> >> In 4.0 we are using SelectById query that hits query cache, which I am
> >> pretty sure is free of this issue.
> >>
> >> Will need to investigate ObjectIdQuery behavior.
> >>
> >> Andrus
> >>
> >>> On May 18, 2016, at 5:22 PM, Frank Herrmann <
> >> frank.herrmann@modernizingmedicine.com> wrote:
> >>>
> >>> Hi Andrus,
> >>>
> >>> Yes, superclass/subclass. We are using Cayenne.objectForQuery(...);
> >>>
> >>> Specifically,
> >>>
> >>> Cayenne.*objectForQuery*(dataContext, *new* ObjectIdQuery(oid, *false*,
> >>> ObjectIdQuery.*CACHE*));
> >>>
> >>> On Wed, May 18, 2016 at 10:11 AM, Andrus Adamchik <
> >> andrus@objectstyle.org>
> >>> wrote:
> >>>
> >>>>> I have a question and an observation. While reading some of the
> Cayenne
> >>>>> code, we've noticed reference to a snapshot cache. Is this the object
> >>>>> cache, or something different?
> >>>>
> >>>> Correct. This is shared object cache.
> >>>>
> >>>>> The issue we are seeing has to do with cayenne objects that are
> >>>>> parents/children of other cayenne objects. For instance, we have a
> User
> >>>>> object, we also have Staff and Patient objects that are children of
> the
> >>>>> User object.
> >>>>
> >>>> By parent/child you mean superclass/subclass?
> >>>>
> >>>>>
> >>>>> What we have seen is that if a developer does a query for a User
> object
> >>>> by
> >>>>> id, the object is retrieved. Cayenne sees that this object is a Staff
> >>>>> object and then stores it in the object cache as a Staff object. The
> >> next
> >>>>> time the user goes to retrieve the User object (by the same id),
> >> Cayenne
> >>>>> does another call to the database, because it cannot find the User
> >> object
> >>>>> in the cache (because it stored it as a Staff object).
> >>>>
> >>>> Could be a bug. Which API are you using? Cayenne.objectForPK(..) ?
> >>>>
> >>>> Andrus
> >>>>
> >>>>
> >>>>
> >>>>> On May 18, 2016, at 4:31 PM, Frank Herrmann <
> >>>> frank.herrmann@modernizingmedicine.com> wrote:
> >>>>>
> >>>>> Hello all,
> >>>>>
> >>>>> I have a question and an observation. While reading some of the
> Cayenne
> >>>>> code, we've noticed reference to a snapshot cache. Is this the object
> >>>>> cache, or something different?
> >>>>>
> >>>>> The issue we are seeing has to do with cayenne objects that are
> >>>>> parents/children of other cayenne objects. For instance, we have a
> User
> >>>>> object, we also have Staff and Patient objects that are children of
> the
> >>>>> User object.
> >>>>>
> >>>>> What we have seen is that if a developer does a query for a User
> object
> >>>> by
> >>>>> id, the object is retrieved. Cayenne sees that this object is a Staff
> >>>>> object and then stores it in the object cache as a Staff object. The
> >> next
> >>>>> time the user goes to retrieve the User object (by the same id),
> >> Cayenne
> >>>>> does another call to the database, because it cannot find the User
> >> object
> >>>>> in the cache (because it stored it as a Staff object).
> >>>>>
> >>>>> Thanks again for the help.
> >>>>>
> >>>>> -Frank
> >>>>>
> >>>>> --
> >>>>> FRANK HERRMANN
> >>>>> SOFTWARE ENGINEER
> >>>>>
> >>>>> T: 561-880-2998 x1563
> >>>>>
> >>>>> E: frank.herrmann@modmed.com
> >>>>>
> >>>>>
> >>>>>
> >>>>> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> >>>>> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> >>>> [image:
> >>>>> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/
> >
> >>>> [image:
> >>>>> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine>
> >> [image: [
> >>>>> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> >>>>> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> >>>>> <http://instagram.com/modernizing_medicine>
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> FRANK HERRMANN
> >>> SOFTWARE ENGINEER
> >>>
> >>> T: 561-880-2998 x1563
> >>>
> >>> E: frank.herrmann@modmed.com
> >>>
> >>>
> >>>
> >>> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> >>> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> >> [image:
> >>> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> >> [image:
> >>> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine>
> [image: [
> >>> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> >>> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> >>> <http://instagram.com/modernizing_medicine>
> >>
> >>
> >
> >
> > --
> > FRANK HERRMANN
> > SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrmann@modmed.com
> >
> >
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine>
>
>


-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrmann@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>

Re: Object Cache and Child Objects - Cayenne 3.1

Posted by Andrus Adamchik <an...@objectstyle.org>.
Just committed a fix to 3.1 and 4.0 branches: https://issues.apache.org/jira/browse/CAY-2084


> On May 18, 2016, at 5:27 PM, Frank Herrmann <fr...@modernizingmedicine.com> wrote:
> 
> Thanks.
> 
> On Wed, May 18, 2016 at 10:25 AM, Andrus Adamchik <an...@objectstyle.org>
> wrote:
> 
>> In 4.0 we are using SelectById query that hits query cache, which I am
>> pretty sure is free of this issue.
>> 
>> Will need to investigate ObjectIdQuery behavior.
>> 
>> Andrus
>> 
>>> On May 18, 2016, at 5:22 PM, Frank Herrmann <
>> frank.herrmann@modernizingmedicine.com> wrote:
>>> 
>>> Hi Andrus,
>>> 
>>> Yes, superclass/subclass. We are using Cayenne.objectForQuery(...);
>>> 
>>> Specifically,
>>> 
>>> Cayenne.*objectForQuery*(dataContext, *new* ObjectIdQuery(oid, *false*,
>>> ObjectIdQuery.*CACHE*));
>>> 
>>> On Wed, May 18, 2016 at 10:11 AM, Andrus Adamchik <
>> andrus@objectstyle.org>
>>> wrote:
>>> 
>>>>> I have a question and an observation. While reading some of the Cayenne
>>>>> code, we've noticed reference to a snapshot cache. Is this the object
>>>>> cache, or something different?
>>>> 
>>>> Correct. This is shared object cache.
>>>> 
>>>>> The issue we are seeing has to do with cayenne objects that are
>>>>> parents/children of other cayenne objects. For instance, we have a User
>>>>> object, we also have Staff and Patient objects that are children of the
>>>>> User object.
>>>> 
>>>> By parent/child you mean superclass/subclass?
>>>> 
>>>>> 
>>>>> What we have seen is that if a developer does a query for a User object
>>>> by
>>>>> id, the object is retrieved. Cayenne sees that this object is a Staff
>>>>> object and then stores it in the object cache as a Staff object. The
>> next
>>>>> time the user goes to retrieve the User object (by the same id),
>> Cayenne
>>>>> does another call to the database, because it cannot find the User
>> object
>>>>> in the cache (because it stored it as a Staff object).
>>>> 
>>>> Could be a bug. Which API are you using? Cayenne.objectForPK(..) ?
>>>> 
>>>> Andrus
>>>> 
>>>> 
>>>> 
>>>>> On May 18, 2016, at 4:31 PM, Frank Herrmann <
>>>> frank.herrmann@modernizingmedicine.com> wrote:
>>>>> 
>>>>> Hello all,
>>>>> 
>>>>> I have a question and an observation. While reading some of the Cayenne
>>>>> code, we've noticed reference to a snapshot cache. Is this the object
>>>>> cache, or something different?
>>>>> 
>>>>> The issue we are seeing has to do with cayenne objects that are
>>>>> parents/children of other cayenne objects. For instance, we have a User
>>>>> object, we also have Staff and Patient objects that are children of the
>>>>> User object.
>>>>> 
>>>>> What we have seen is that if a developer does a query for a User object
>>>> by
>>>>> id, the object is retrieved. Cayenne sees that this object is a Staff
>>>>> object and then stores it in the object cache as a Staff object. The
>> next
>>>>> time the user goes to retrieve the User object (by the same id),
>> Cayenne
>>>>> does another call to the database, because it cannot find the User
>> object
>>>>> in the cache (because it stored it as a Staff object).
>>>>> 
>>>>> Thanks again for the help.
>>>>> 
>>>>> -Frank
>>>>> 
>>>>> --
>>>>> FRANK HERRMANN
>>>>> SOFTWARE ENGINEER
>>>>> 
>>>>> T: 561-880-2998 x1563
>>>>> 
>>>>> E: frank.herrmann@modmed.com
>>>>> 
>>>>> 
>>>>> 
>>>>> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
>>>>> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
>>>> [image:
>>>>> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
>>>> [image:
>>>>> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine>
>> [image: [
>>>>> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
>>>>> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
>>>>> <http://instagram.com/modernizing_medicine>
>>>> 
>>>> 
>>> 
>>> 
>>> --
>>> FRANK HERRMANN
>>> SOFTWARE ENGINEER
>>> 
>>> T: 561-880-2998 x1563
>>> 
>>> E: frank.herrmann@modmed.com
>>> 
>>> 
>>> 
>>> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
>>> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
>> [image:
>>> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
>> [image:
>>> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
>>> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
>>> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
>>> <http://instagram.com/modernizing_medicine>
>> 
>> 
> 
> 
> -- 
> FRANK HERRMANN
> SOFTWARE ENGINEER
> 
> T: 561-880-2998 x1563
> 
> E: frank.herrmann@modmed.com
> 
> 
> 
> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> <http://instagram.com/modernizing_medicine>


Re: Object Cache and Child Objects - Cayenne 3.1

Posted by Frank Herrmann <fr...@modernizingmedicine.com>.
Thanks.

On Wed, May 18, 2016 at 10:25 AM, Andrus Adamchik <an...@objectstyle.org>
wrote:

> In 4.0 we are using SelectById query that hits query cache, which I am
> pretty sure is free of this issue.
>
> Will need to investigate ObjectIdQuery behavior.
>
> Andrus
>
> > On May 18, 2016, at 5:22 PM, Frank Herrmann <
> frank.herrmann@modernizingmedicine.com> wrote:
> >
> > Hi Andrus,
> >
> > Yes, superclass/subclass. We are using Cayenne.objectForQuery(...);
> >
> > Specifically,
> >
> > Cayenne.*objectForQuery*(dataContext, *new* ObjectIdQuery(oid, *false*,
> > ObjectIdQuery.*CACHE*));
> >
> > On Wed, May 18, 2016 at 10:11 AM, Andrus Adamchik <
> andrus@objectstyle.org>
> > wrote:
> >
> >>> I have a question and an observation. While reading some of the Cayenne
> >>> code, we've noticed reference to a snapshot cache. Is this the object
> >>> cache, or something different?
> >>
> >> Correct. This is shared object cache.
> >>
> >>> The issue we are seeing has to do with cayenne objects that are
> >>> parents/children of other cayenne objects. For instance, we have a User
> >>> object, we also have Staff and Patient objects that are children of the
> >>> User object.
> >>
> >> By parent/child you mean superclass/subclass?
> >>
> >>>
> >>> What we have seen is that if a developer does a query for a User object
> >> by
> >>> id, the object is retrieved. Cayenne sees that this object is a Staff
> >>> object and then stores it in the object cache as a Staff object. The
> next
> >>> time the user goes to retrieve the User object (by the same id),
> Cayenne
> >>> does another call to the database, because it cannot find the User
> object
> >>> in the cache (because it stored it as a Staff object).
> >>
> >> Could be a bug. Which API are you using? Cayenne.objectForPK(..) ?
> >>
> >> Andrus
> >>
> >>
> >>
> >>> On May 18, 2016, at 4:31 PM, Frank Herrmann <
> >> frank.herrmann@modernizingmedicine.com> wrote:
> >>>
> >>> Hello all,
> >>>
> >>> I have a question and an observation. While reading some of the Cayenne
> >>> code, we've noticed reference to a snapshot cache. Is this the object
> >>> cache, or something different?
> >>>
> >>> The issue we are seeing has to do with cayenne objects that are
> >>> parents/children of other cayenne objects. For instance, we have a User
> >>> object, we also have Staff and Patient objects that are children of the
> >>> User object.
> >>>
> >>> What we have seen is that if a developer does a query for a User object
> >> by
> >>> id, the object is retrieved. Cayenne sees that this object is a Staff
> >>> object and then stores it in the object cache as a Staff object. The
> next
> >>> time the user goes to retrieve the User object (by the same id),
> Cayenne
> >>> does another call to the database, because it cannot find the User
> object
> >>> in the cache (because it stored it as a Staff object).
> >>>
> >>> Thanks again for the help.
> >>>
> >>> -Frank
> >>>
> >>> --
> >>> FRANK HERRMANN
> >>> SOFTWARE ENGINEER
> >>>
> >>> T: 561-880-2998 x1563
> >>>
> >>> E: frank.herrmann@modmed.com
> >>>
> >>>
> >>>
> >>> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> >>> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> >> [image:
> >>> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> >> [image:
> >>> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine>
> [image: [
> >>> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> >>> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> >>> <http://instagram.com/modernizing_medicine>
> >>
> >>
> >
> >
> > --
> > FRANK HERRMANN
> > SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrmann@modmed.com
> >
> >
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine>
>
>


-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrmann@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>

Re: Object Cache and Child Objects - Cayenne 3.1

Posted by Andrus Adamchik <an...@objectstyle.org>.
In 4.0 we are using SelectById query that hits query cache, which I am pretty sure is free of this issue.

Will need to investigate ObjectIdQuery behavior.

Andrus

> On May 18, 2016, at 5:22 PM, Frank Herrmann <fr...@modernizingmedicine.com> wrote:
> 
> Hi Andrus,
> 
> Yes, superclass/subclass. We are using Cayenne.objectForQuery(...);
> 
> Specifically,
> 
> Cayenne.*objectForQuery*(dataContext, *new* ObjectIdQuery(oid, *false*,
> ObjectIdQuery.*CACHE*));
> 
> On Wed, May 18, 2016 at 10:11 AM, Andrus Adamchik <an...@objectstyle.org>
> wrote:
> 
>>> I have a question and an observation. While reading some of the Cayenne
>>> code, we've noticed reference to a snapshot cache. Is this the object
>>> cache, or something different?
>> 
>> Correct. This is shared object cache.
>> 
>>> The issue we are seeing has to do with cayenne objects that are
>>> parents/children of other cayenne objects. For instance, we have a User
>>> object, we also have Staff and Patient objects that are children of the
>>> User object.
>> 
>> By parent/child you mean superclass/subclass?
>> 
>>> 
>>> What we have seen is that if a developer does a query for a User object
>> by
>>> id, the object is retrieved. Cayenne sees that this object is a Staff
>>> object and then stores it in the object cache as a Staff object. The next
>>> time the user goes to retrieve the User object (by the same id), Cayenne
>>> does another call to the database, because it cannot find the User object
>>> in the cache (because it stored it as a Staff object).
>> 
>> Could be a bug. Which API are you using? Cayenne.objectForPK(..) ?
>> 
>> Andrus
>> 
>> 
>> 
>>> On May 18, 2016, at 4:31 PM, Frank Herrmann <
>> frank.herrmann@modernizingmedicine.com> wrote:
>>> 
>>> Hello all,
>>> 
>>> I have a question and an observation. While reading some of the Cayenne
>>> code, we've noticed reference to a snapshot cache. Is this the object
>>> cache, or something different?
>>> 
>>> The issue we are seeing has to do with cayenne objects that are
>>> parents/children of other cayenne objects. For instance, we have a User
>>> object, we also have Staff and Patient objects that are children of the
>>> User object.
>>> 
>>> What we have seen is that if a developer does a query for a User object
>> by
>>> id, the object is retrieved. Cayenne sees that this object is a Staff
>>> object and then stores it in the object cache as a Staff object. The next
>>> time the user goes to retrieve the User object (by the same id), Cayenne
>>> does another call to the database, because it cannot find the User object
>>> in the cache (because it stored it as a Staff object).
>>> 
>>> Thanks again for the help.
>>> 
>>> -Frank
>>> 
>>> --
>>> FRANK HERRMANN
>>> SOFTWARE ENGINEER
>>> 
>>> T: 561-880-2998 x1563
>>> 
>>> E: frank.herrmann@modmed.com
>>> 
>>> 
>>> 
>>> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
>>> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
>> [image:
>>> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
>> [image:
>>> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
>>> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
>>> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
>>> <http://instagram.com/modernizing_medicine>
>> 
>> 
> 
> 
> -- 
> FRANK HERRMANN
> SOFTWARE ENGINEER
> 
> T: 561-880-2998 x1563
> 
> E: frank.herrmann@modmed.com
> 
> 
> 
> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> <http://instagram.com/modernizing_medicine>


Re: Object Cache and Child Objects - Cayenne 3.1

Posted by Frank Herrmann <fr...@modernizingmedicine.com>.
Hi Andrus,

Yes, superclass/subclass. We are using Cayenne.objectForQuery(...);

Specifically,

Cayenne.*objectForQuery*(dataContext, *new* ObjectIdQuery(oid, *false*,
ObjectIdQuery.*CACHE*));

On Wed, May 18, 2016 at 10:11 AM, Andrus Adamchik <an...@objectstyle.org>
wrote:

> > I have a question and an observation. While reading some of the Cayenne
> > code, we've noticed reference to a snapshot cache. Is this the object
> > cache, or something different?
>
> Correct. This is shared object cache.
>
> > The issue we are seeing has to do with cayenne objects that are
> > parents/children of other cayenne objects. For instance, we have a User
> > object, we also have Staff and Patient objects that are children of the
> > User object.
>
> By parent/child you mean superclass/subclass?
>
> >
> > What we have seen is that if a developer does a query for a User object
> by
> > id, the object is retrieved. Cayenne sees that this object is a Staff
> > object and then stores it in the object cache as a Staff object. The next
> > time the user goes to retrieve the User object (by the same id), Cayenne
> > does another call to the database, because it cannot find the User object
> > in the cache (because it stored it as a Staff object).
>
> Could be a bug. Which API are you using? Cayenne.objectForPK(..) ?
>
> Andrus
>
>
>
> > On May 18, 2016, at 4:31 PM, Frank Herrmann <
> frank.herrmann@modernizingmedicine.com> wrote:
> >
> > Hello all,
> >
> > I have a question and an observation. While reading some of the Cayenne
> > code, we've noticed reference to a snapshot cache. Is this the object
> > cache, or something different?
> >
> > The issue we are seeing has to do with cayenne objects that are
> > parents/children of other cayenne objects. For instance, we have a User
> > object, we also have Staff and Patient objects that are children of the
> > User object.
> >
> > What we have seen is that if a developer does a query for a User object
> by
> > id, the object is retrieved. Cayenne sees that this object is a Staff
> > object and then stores it in the object cache as a Staff object. The next
> > time the user goes to retrieve the User object (by the same id), Cayenne
> > does another call to the database, because it cannot find the User object
> > in the cache (because it stored it as a Staff object).
> >
> > Thanks again for the help.
> >
> > -Frank
> >
> > --
> > FRANK HERRMANN
> > SOFTWARE ENGINEER
> >
> > T: 561-880-2998 x1563
> >
> > E: frank.herrmann@modmed.com
> >
> >
> >
> > [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> > [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine>
> [image:
> > [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/>
> [image:
> > [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> > Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> > <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> > <http://instagram.com/modernizing_medicine>
>
>


-- 
FRANK HERRMANN
SOFTWARE ENGINEER

T: 561-880-2998 x1563

E: frank.herrmann@modmed.com



[image: [ Modernizing Medicine ]] <http://www.modmed.com/>
[image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
[ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
[ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
<http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
<http://instagram.com/modernizing_medicine>

Re: Object Cache and Child Objects - Cayenne 3.1

Posted by Andrus Adamchik <an...@objectstyle.org>.
> I have a question and an observation. While reading some of the Cayenne
> code, we've noticed reference to a snapshot cache. Is this the object
> cache, or something different?

Correct. This is shared object cache.

> The issue we are seeing has to do with cayenne objects that are
> parents/children of other cayenne objects. For instance, we have a User
> object, we also have Staff and Patient objects that are children of the
> User object.

By parent/child you mean superclass/subclass?

> 
> What we have seen is that if a developer does a query for a User object by
> id, the object is retrieved. Cayenne sees that this object is a Staff
> object and then stores it in the object cache as a Staff object. The next
> time the user goes to retrieve the User object (by the same id), Cayenne
> does another call to the database, because it cannot find the User object
> in the cache (because it stored it as a Staff object).

Could be a bug. Which API are you using? Cayenne.objectForPK(..) ?

Andrus



> On May 18, 2016, at 4:31 PM, Frank Herrmann <fr...@modernizingmedicine.com> wrote:
> 
> Hello all,
> 
> I have a question and an observation. While reading some of the Cayenne
> code, we've noticed reference to a snapshot cache. Is this the object
> cache, or something different?
> 
> The issue we are seeing has to do with cayenne objects that are
> parents/children of other cayenne objects. For instance, we have a User
> object, we also have Staff and Patient objects that are children of the
> User object.
> 
> What we have seen is that if a developer does a query for a User object by
> id, the object is retrieved. Cayenne sees that this object is a Staff
> object and then stores it in the object cache as a Staff object. The next
> time the user goes to retrieve the User object (by the same id), Cayenne
> does another call to the database, because it cannot find the User object
> in the cache (because it stored it as a Staff object).
> 
> Thanks again for the help.
> 
> -Frank
> 
> -- 
> FRANK HERRMANN
> SOFTWARE ENGINEER
> 
> T: 561-880-2998 x1563
> 
> E: frank.herrmann@modmed.com
> 
> 
> 
> [image: [ Modernizing Medicine ]] <http://www.modmed.com/>
> [image: [ Facebook ]] <http://www.facebook.com/modernizingmedicine> [image:
> [ LinkedIn ]] <http://www.linkedin.com/company/modernizing-medicine/> [image:
> [ YouTube ]] <http://www.youtube.com/user/modernizingmedicine> [image: [
> Twitter ]] <https://twitter.com/modmed_EMA> [image: [ Blog ]]
> <http://www.modmed.com/BlogBeyondEMR> [image: [ Instagram ]]
> <http://instagram.com/modernizing_medicine>