You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Kevin Sutter <kw...@gmail.com> on 2007/10/04 22:59:05 UTC
em.refresh() semantics
Hi,
>From reading the spec and the Pro EJB 3 book, I was under the impression
that a call to em.refresh() would refresh from the database regardless. No
questions asked. But, I am finding that we don't work that way. I made a
simple update to our simple PersistenceTest using the AllFieldTypes
(non-versioned) and NamedEntity (versioned) objects. And, neither one will
load when refresh() is called. For some reason, with the AllFieldTypes,
none of the fields are being detected as being updated. And, with the
NamedEntity, since the version field hasn't been updated, then it doesn't
refresh the rest of the object.
>From my reading, this doesn't sound like proper processing. But, before I
start making any changes, I'm looking for alternate interpretations of the
spec. Thanks.
I've attached a patch for PersistenceTest, if you are interested in trying
it out.
Kevin
Re: em.refresh() semantics
Posted by Patrick Linskey <pl...@gmail.com>.
Sounds like a new issue. Can you link it to the existing issue though?
Maybe mark it as a sub-task?
-Patrick
On 10/9/07, Kevin Sutter <kw...@gmail.com> wrote:
> Okay, I'm narrowing in on this problem. It seems to be related to the
> automatic runtime enhancement. Given my simple update to the
> TestPersistence testcase that I posted earlier to this thread and not
> statically pre-enhancing the Entities will easily reproduce the problem. It
> seems that the automatic PC subclassing is not properly detecting updates to
> the Entities and, thus, when we do a refresh(), there's nothing to indicate
> that the Entity is dirty and, thus, no reload from the database.
>
> If I change the scenario and do the pre-enhancement, then the setting of the
> attributes on AllFieldTypes and NamedEntity will properly dirty the Entities
> and they will be reloaded when the refresh() is invoked.
>
> Is this one of the known limitations with the automatic runtime enhancement
> or is a JIRA Issue required to track this problem?
>
> Thanks,
> Kevin
>
> On 10/4/07, Kevin Sutter <kw...@gmail.com> wrote:
> >
> > Pinaki,
> > No caching is turned on. The only cache that I am aware of that is turned
> > on by default is the Query Compilation Cache. All other caches need to be
> > explicitly configured. I have not configured for any caches. I am running
> > with the standard "test" persistence unit definition in our
> > persistence.xml file.
> >
> > Kevin
> >
> > On 10/4/07, Pinaki Poddar <pp...@bea.com> wrote:
> > >
> > > Is L2 cache configured for this experiment? If datacache is active, then
> > > that the state may be delivered from there itself without hitting the
> > > database.
> > > Does the test behave differently, if you set
> > > a) datacahe off
> > > or b) evict from both L1 and L2 cache before refresh?
> > > To ensure that em.evict() acts on L2 cahce too, please set <property
> > > name="openjpa.BrokerImpl" value="EvictFromDataCache=true"/>
> > >
> > > Pinaki Poddar
> > > 972.834.2865
> > >
> > >
> > > >-----Original Message-----
> > > >From: Kevin Sutter [mailto:kwsutter@gmail.com]
> > > >Sent: Thursday, October 04, 2007 3:59 PM
> > > >To: dev@openjpa.apache.org
> > > >Subject: em.refresh() semantics
> > > >
> > > >Hi,
> > > >From reading the spec and the Pro EJB 3 book, I was under the
> > > >impression that a call to em.refresh() would refresh from the
> > > >database regardless. No questions asked. But, I am finding
> > > >that we don't work that way. I made a simple update to our
> > > >simple PersistenceTest using the AllFieldTypes (non-versioned)
> > > >and NamedEntity (versioned) objects. And, neither one will
> > > >load when refresh() is called. For some reason, with the
> > > >AllFieldTypes, none of the fields are being detected as being
> > > >updated. And, with the NamedEntity, since the version field
> > > >hasn't been updated, then it doesn't refresh the rest of the object.
> > > >
> > > >From my reading, this doesn't sound like proper processing.
> > > >But, before I start making any changes, I'm looking for
> > > >alternate interpretations of the spec. Thanks.
> > > >
> > > >I've attached a patch for PersistenceTest, if you are
> > > >interested in trying it out.
> > > >
> > > >Kevin
> > > >
> > > >
> > >
> > > Notice: This email message, together with any attachments, may contain
> > > information of BEA Systems, Inc., its subsidiaries and affiliated
> > > entities, that may be confidential, proprietary, copyrighted and/or
> > > legally privileged, and is intended solely for the use of the individual or
> > > entity named in this message. If you are not the intended recipient, and
> > > have received this message in error, please immediately return this by email
> > > and then delete it.
> > >
> >
> >
>
--
Patrick Linskey
202 669 5907
Re: em.refresh() semantics
Posted by Kevin Sutter <kw...@gmail.com>.
Marina,
On 10/9/07, Marina Vatkina <Ma...@sun.com> wrote:
>
>
> Shouldn't refresh() ignore the state of an entity? How would an EM know if
> the
> data in the database has changed or not?
This was my first response as well. But, when I started to experience the
non-refreshing of the Entities, I was wondering whether we were attempting
to be smart (or efficient) with this refresh. In turns out that we are more
efficient when we can be. For example, if I attempt to refresh a
non-versioned Entity (with the proper pre-enhancement step), then we do
ignore the state of the Entity and reload it from the database. So, even if
I don't modify the Entity and call refresh() on this non-versioned Entity,
the refresh still happens.
If I attempt to refresh a versioned Entity (with the proper pre-enhancement
step), then we do two checks. First, we determine if the Entity has been
dirtied or not. If so, we refresh from the database. If it has not been
dirtied, then we check the version field from the database before reloading
the whole Entity.
So, with the proper pre-enhancement of the Entities, then the refresh() is
working as I had originally hoped.
Kevin
thanks,
> -marina
>
> Kevin Sutter wrote:
> > Okay, I'm narrowing in on this problem. It seems to be related to the
> > automatic runtime enhancement. Given my simple update to the
> > TestPersistence testcase that I posted earlier to this thread and not
> > statically pre-enhancing the Entities will easily reproduce the
> problem. It
> > seems that the automatic PC subclassing is not properly detecting
> updates to
> > the Entities and, thus, when we do a refresh(), there's nothing to
> indicate
> > that the Entity is dirty and, thus, no reload from the database.
> >
> > If I change the scenario and do the pre-enhancement, then the setting of
> the
> > attributes on AllFieldTypes and NamedEntity will properly dirty the
> Entities
> > and they will be reloaded when the refresh() is invoked.
> >
> > Is this one of the known limitations with the automatic runtime
> enhancement
> > or is a JIRA Issue required to track this problem?
> >
> > Thanks,
> > Kevin
> >
> > On 10/4/07, Kevin Sutter <kw...@gmail.com> wrote:
> >
> >>Pinaki,
> >>No caching is turned on. The only cache that I am aware of that is
> turned
> >>on by default is the Query Compilation Cache. All other caches need to
> be
> >>explicitly configured. I have not configured for any caches. I am
> running
> >>with the standard "test" persistence unit definition in our
> >>persistence.xml file.
> >>
> >>Kevin
> >>
> >>On 10/4/07, Pinaki Poddar <pp...@bea.com> wrote:
> >>
> >>>Is L2 cache configured for this experiment? If datacache is active,
> then
> >>>that the state may be delivered from there itself without hitting the
> >>>database.
> >>>Does the test behave differently, if you set
> >>> a) datacahe off
> >>>or b) evict from both L1 and L2 cache before refresh?
> >>> To ensure that em.evict() acts on L2 cahce too, please set
> <property
> >>>name="openjpa.BrokerImpl" value="EvictFromDataCache=true"/>
> >>>
> >>>Pinaki Poddar
> >>>972.834.2865
> >>>
> >>>
> >>>
> >>>>-----Original Message-----
> >>>>From: Kevin Sutter [mailto:kwsutter@gmail.com]
> >>>>Sent: Thursday, October 04, 2007 3:59 PM
> >>>>To: dev@openjpa.apache.org
> >>>>Subject: em.refresh() semantics
> >>>>
> >>>>Hi,
> >>>
> >>>>From reading the spec and the Pro EJB 3 book, I was under the
> >>>
> >>>>impression that a call to em.refresh() would refresh from the
> >>>>database regardless. No questions asked. But, I am finding
> >>>>that we don't work that way. I made a simple update to our
> >>>>simple PersistenceTest using the AllFieldTypes (non-versioned)
> >>>>and NamedEntity (versioned) objects. And, neither one will
> >>>>load when refresh() is called. For some reason, with the
> >>>>AllFieldTypes, none of the fields are being detected as being
> >>>>updated. And, with the NamedEntity, since the version field
> >>>>hasn't been updated, then it doesn't refresh the rest of the object.
> >>>>
> >>>
> >>>>From my reading, this doesn't sound like proper processing.
> >>>
> >>>>But, before I start making any changes, I'm looking for
> >>>>alternate interpretations of the spec. Thanks.
> >>>>
> >>>>I've attached a patch for PersistenceTest, if you are
> >>>>interested in trying it out.
> >>>>
> >>>>Kevin
> >>>>
> >>>>
> >>>
> >>>Notice: This email message, together with any attachments, may contain
> >>>information of BEA Systems, Inc., its subsidiaries and affiliated
> >>>entities, that may be confidential, proprietary, copyrighted and/or
> >>>legally privileged, and is intended solely for the use of the
> individual or
> >>>entity named in this message. If you are not the intended recipient,
> and
> >>>have received this message in error, please immediately return this by
> email
> >>>and then delete it.
> >>>
> >>
> >>
> >
>
>
Re: em.refresh() semantics
Posted by Marina Vatkina <Ma...@Sun.COM>.
Kevin,
Shouldn't refresh() ignore the state of an entity? How would an EM know if the
data in the database has changed or not?
thanks,
-marina
Kevin Sutter wrote:
> Okay, I'm narrowing in on this problem. It seems to be related to the
> automatic runtime enhancement. Given my simple update to the
> TestPersistence testcase that I posted earlier to this thread and not
> statically pre-enhancing the Entities will easily reproduce the problem. It
> seems that the automatic PC subclassing is not properly detecting updates to
> the Entities and, thus, when we do a refresh(), there's nothing to indicate
> that the Entity is dirty and, thus, no reload from the database.
>
> If I change the scenario and do the pre-enhancement, then the setting of the
> attributes on AllFieldTypes and NamedEntity will properly dirty the Entities
> and they will be reloaded when the refresh() is invoked.
>
> Is this one of the known limitations with the automatic runtime enhancement
> or is a JIRA Issue required to track this problem?
>
> Thanks,
> Kevin
>
> On 10/4/07, Kevin Sutter <kw...@gmail.com> wrote:
>
>>Pinaki,
>>No caching is turned on. The only cache that I am aware of that is turned
>>on by default is the Query Compilation Cache. All other caches need to be
>>explicitly configured. I have not configured for any caches. I am running
>>with the standard "test" persistence unit definition in our
>>persistence.xml file.
>>
>>Kevin
>>
>>On 10/4/07, Pinaki Poddar <pp...@bea.com> wrote:
>>
>>>Is L2 cache configured for this experiment? If datacache is active, then
>>>that the state may be delivered from there itself without hitting the
>>>database.
>>>Does the test behave differently, if you set
>>> a) datacahe off
>>>or b) evict from both L1 and L2 cache before refresh?
>>> To ensure that em.evict() acts on L2 cahce too, please set <property
>>>name="openjpa.BrokerImpl" value="EvictFromDataCache=true"/>
>>>
>>>Pinaki Poddar
>>>972.834.2865
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: Kevin Sutter [mailto:kwsutter@gmail.com]
>>>>Sent: Thursday, October 04, 2007 3:59 PM
>>>>To: dev@openjpa.apache.org
>>>>Subject: em.refresh() semantics
>>>>
>>>>Hi,
>>>
>>>>>From reading the spec and the Pro EJB 3 book, I was under the
>>>
>>>>impression that a call to em.refresh() would refresh from the
>>>>database regardless. No questions asked. But, I am finding
>>>>that we don't work that way. I made a simple update to our
>>>>simple PersistenceTest using the AllFieldTypes (non-versioned)
>>>>and NamedEntity (versioned) objects. And, neither one will
>>>>load when refresh() is called. For some reason, with the
>>>>AllFieldTypes, none of the fields are being detected as being
>>>>updated. And, with the NamedEntity, since the version field
>>>>hasn't been updated, then it doesn't refresh the rest of the object.
>>>>
>>>
>>>>>From my reading, this doesn't sound like proper processing.
>>>
>>>>But, before I start making any changes, I'm looking for
>>>>alternate interpretations of the spec. Thanks.
>>>>
>>>>I've attached a patch for PersistenceTest, if you are
>>>>interested in trying it out.
>>>>
>>>>Kevin
>>>>
>>>>
>>>
>>>Notice: This email message, together with any attachments, may contain
>>>information of BEA Systems, Inc., its subsidiaries and affiliated
>>>entities, that may be confidential, proprietary, copyrighted and/or
>>>legally privileged, and is intended solely for the use of the individual or
>>>entity named in this message. If you are not the intended recipient, and
>>>have received this message in error, please immediately return this by email
>>>and then delete it.
>>>
>>
>>
>
Re: em.refresh() semantics
Posted by Kevin Sutter <kw...@gmail.com>.
Okay, I'm narrowing in on this problem. It seems to be related to the
automatic runtime enhancement. Given my simple update to the
TestPersistence testcase that I posted earlier to this thread and not
statically pre-enhancing the Entities will easily reproduce the problem. It
seems that the automatic PC subclassing is not properly detecting updates to
the Entities and, thus, when we do a refresh(), there's nothing to indicate
that the Entity is dirty and, thus, no reload from the database.
If I change the scenario and do the pre-enhancement, then the setting of the
attributes on AllFieldTypes and NamedEntity will properly dirty the Entities
and they will be reloaded when the refresh() is invoked.
Is this one of the known limitations with the automatic runtime enhancement
or is a JIRA Issue required to track this problem?
Thanks,
Kevin
On 10/4/07, Kevin Sutter <kw...@gmail.com> wrote:
>
> Pinaki,
> No caching is turned on. The only cache that I am aware of that is turned
> on by default is the Query Compilation Cache. All other caches need to be
> explicitly configured. I have not configured for any caches. I am running
> with the standard "test" persistence unit definition in our
> persistence.xml file.
>
> Kevin
>
> On 10/4/07, Pinaki Poddar <pp...@bea.com> wrote:
> >
> > Is L2 cache configured for this experiment? If datacache is active, then
> > that the state may be delivered from there itself without hitting the
> > database.
> > Does the test behave differently, if you set
> > a) datacahe off
> > or b) evict from both L1 and L2 cache before refresh?
> > To ensure that em.evict() acts on L2 cahce too, please set <property
> > name="openjpa.BrokerImpl" value="EvictFromDataCache=true"/>
> >
> > Pinaki Poddar
> > 972.834.2865
> >
> >
> > >-----Original Message-----
> > >From: Kevin Sutter [mailto:kwsutter@gmail.com]
> > >Sent: Thursday, October 04, 2007 3:59 PM
> > >To: dev@openjpa.apache.org
> > >Subject: em.refresh() semantics
> > >
> > >Hi,
> > >From reading the spec and the Pro EJB 3 book, I was under the
> > >impression that a call to em.refresh() would refresh from the
> > >database regardless. No questions asked. But, I am finding
> > >that we don't work that way. I made a simple update to our
> > >simple PersistenceTest using the AllFieldTypes (non-versioned)
> > >and NamedEntity (versioned) objects. And, neither one will
> > >load when refresh() is called. For some reason, with the
> > >AllFieldTypes, none of the fields are being detected as being
> > >updated. And, with the NamedEntity, since the version field
> > >hasn't been updated, then it doesn't refresh the rest of the object.
> > >
> > >From my reading, this doesn't sound like proper processing.
> > >But, before I start making any changes, I'm looking for
> > >alternate interpretations of the spec. Thanks.
> > >
> > >I've attached a patch for PersistenceTest, if you are
> > >interested in trying it out.
> > >
> > >Kevin
> > >
> > >
> >
> > Notice: This email message, together with any attachments, may contain
> > information of BEA Systems, Inc., its subsidiaries and affiliated
> > entities, that may be confidential, proprietary, copyrighted and/or
> > legally privileged, and is intended solely for the use of the individual or
> > entity named in this message. If you are not the intended recipient, and
> > have received this message in error, please immediately return this by email
> > and then delete it.
> >
>
>
Re: em.refresh() semantics
Posted by Kevin Sutter <kw...@gmail.com>.
Pinaki,
No caching is turned on. The only cache that I am aware of that is turned
on by default is the Query Compilation Cache. All other caches need to be
explicitly configured. I have not configured for any caches. I am running
with the standard "test" persistence unit definition in our persistence.xmlfile.
Kevin
On 10/4/07, Pinaki Poddar <pp...@bea.com> wrote:
>
> Is L2 cache configured for this experiment? If datacache is active, then
> that the state may be delivered from there itself without hitting the
> database.
> Does the test behave differently, if you set
> a) datacahe off
> or b) evict from both L1 and L2 cache before refresh?
> To ensure that em.evict() acts on L2 cahce too, please set <property
> name="openjpa.BrokerImpl" value="EvictFromDataCache=true"/>
>
> Pinaki Poddar
> 972.834.2865
>
>
> >-----Original Message-----
> >From: Kevin Sutter [mailto:kwsutter@gmail.com]
> >Sent: Thursday, October 04, 2007 3:59 PM
> >To: dev@openjpa.apache.org
> >Subject: em.refresh() semantics
> >
> >Hi,
> >From reading the spec and the Pro EJB 3 book, I was under the
> >impression that a call to em.refresh() would refresh from the
> >database regardless. No questions asked. But, I am finding
> >that we don't work that way. I made a simple update to our
> >simple PersistenceTest using the AllFieldTypes (non-versioned)
> >and NamedEntity (versioned) objects. And, neither one will
> >load when refresh() is called. For some reason, with the
> >AllFieldTypes, none of the fields are being detected as being
> >updated. And, with the NamedEntity, since the version field
> >hasn't been updated, then it doesn't refresh the rest of the object.
> >
> >From my reading, this doesn't sound like proper processing.
> >But, before I start making any changes, I'm looking for
> >alternate interpretations of the spec. Thanks.
> >
> >I've attached a patch for PersistenceTest, if you are
> >interested in trying it out.
> >
> >Kevin
> >
> >
>
> Notice: This email message, together with any attachments, may contain
> information of BEA Systems, Inc., its subsidiaries and affiliated
> entities, that may be confidential, proprietary, copyrighted and/or
> legally privileged, and is intended solely for the use of the individual or
> entity named in this message. If you are not the intended recipient, and
> have received this message in error, please immediately return this by email
> and then delete it.
>
RE: em.refresh() semantics
Posted by Pinaki Poddar <pp...@bea.com>.
Is L2 cache configured for this experiment? If datacache is active, then
that the state may be delivered from there itself without hitting the
database.
Does the test behave differently, if you set
a) datacahe off
or b) evict from both L1 and L2 cache before refresh?
To ensure that em.evict() acts on L2 cahce too, please set <property
name="openjpa.BrokerImpl" value="EvictFromDataCache=true"/>
Pinaki Poddar
972.834.2865
>-----Original Message-----
>From: Kevin Sutter [mailto:kwsutter@gmail.com]
>Sent: Thursday, October 04, 2007 3:59 PM
>To: dev@openjpa.apache.org
>Subject: em.refresh() semantics
>
>Hi,
>>From reading the spec and the Pro EJB 3 book, I was under the
>impression that a call to em.refresh() would refresh from the
>database regardless. No questions asked. But, I am finding
>that we don't work that way. I made a simple update to our
>simple PersistenceTest using the AllFieldTypes (non-versioned)
>and NamedEntity (versioned) objects. And, neither one will
>load when refresh() is called. For some reason, with the
>AllFieldTypes, none of the fields are being detected as being
>updated. And, with the NamedEntity, since the version field
>hasn't been updated, then it doesn't refresh the rest of the object.
>
>>From my reading, this doesn't sound like proper processing.
>But, before I start making any changes, I'm looking for
>alternate interpretations of the spec. Thanks.
>
>I've attached a patch for PersistenceTest, if you are
>interested in trying it out.
>
>Kevin
>
>
Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.