You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by 玉米老 <wa...@gmail.com> on 2011/02/01 07:45:33 UTC

Re: OpenJPA 2.1 clear() is very slow.

Hello Rick and Mark,
First of all, I appreciate your quick response very much.

As your advices, I have opened the OpenJPA trace log and tried to
figure out what did it really do when clear() method of Entity Manager
was invoked.

Please let me introduce my scenario first.
I have two table one is master and another is slave.The slave entity
list is LAZY loaded.
My case is every time I try to get a list of master table entity,
clear() method of Entity Manager will be invoked first to make sure
latest entities will be retrieved. In addition, slave entities seldom
be loaded in my scenario.

But from trace log I found clear() method always try to load all slave
entities and then detach all master and slave entities. I guest that's
the exact root cause why clear() method is so slow.

And I found upgrading to 1.2.2 and adding below line into
persistence.xml doesn't really make any improvements.
                        <property name="openjpa.Compatibility"
value="ReloadOnDetach=false, FlushBeforeDetach=false"/>

Any suggestions?

Regards,
Yu Wang

On Tue, Feb 1, 2011 at 12:15 AM, Rick Curtis <cu...@gmail.com> wrote:
> Yu -
>
> When you call em.clear(), any idea on how many Entities are in your
> persistence context? Could you provide some sort of pseudo code as to the
> scenario that you are running?
>
> Thanks,
> Rick
> On Mon, Jan 31, 2011 at 4:16 AM, 玉米老 <wa...@gmail.com> wrote:
>
>> Hello,
>> I upgraded into 1.2.2 and added below line into persistence.xml but it
>> doesn't really work. In fact I found clere() is still time consuming.
>> Any suggestions?
>>  <property name="openjpa.Compatibility"
>>                            value="ReloadOnDetach=false,
>> FlushBeforeDetach=false"/>
>>
>> Regards,
>> Yu Wang
>>
>> On Mon, Jan 31, 2011 at 2:53 PM, 玉米老 <wa...@gmail.com> wrote:
>> > I guess this may be relevant:
>> >
>> > https://issues.apache.org/jira/browse/OPENJPA-1414
>> >
>> > On Mon, Jan 31, 2011 at 1:32 PM, 玉米老 <wa...@gmail.com> wrote:
>> >> sorry, I'm using OpenJPA 1.2.1 not 2.1
>> >>
>> >> On Mon, Jan 31, 2011 at 1:26 PM, 玉米老 <wa...@gmail.com> wrote:
>> >>> Hello experts:
>> >>> I found sometimes invoking clear() method of entity manager will took
>> >>> more than 30 seconds.
>> >>> I don't know if there' re some performance issues or I shouldn't
>> >>> invoke clear() method first to get updated objects?
>> >>>
>> >>> Regards,
>> >>> Yu Wang
>> >>>
>> >>
>> >
>>
>

Re: OpenJPA 2.1 clear() is very slow.

Posted by Michael Dick <mi...@gmail.com>.
Hi,

I'm glad it helped.

OpenJPA is very configurable when it comes to detached objects, and will use
the DetachState setting if you merge an entity back into the persistence
context.

Here's a link to the doc that might be good to read, in addition to the one
I sent earlier:
http://openjpa.apache.org/builds/apache-openjpa-1.2.3-SNAPSHOT/docs/manual/manual.html#ref_guide_detach
.

-mike

On Tue, Feb 8, 2011 at 8:59 PM, 玉米老 <wa...@gmail.com> wrote:

> Mike,
> You're right, I set : openjpa.DetachState="all".
> Thank you very much!
>
> Regards,
> Yu Wang
>
> On Tue, Feb 1, 2011 at 10:37 PM, Michael Dick <mi...@gmail.com>
> wrote:
> > Hi,
> >
> > Do you have any other openjpa properties set in persistence.xml?
> > Specifically the openjpa.DetachState property can affect which entities
> are
> > loaded when you clear, or manually detach entities.
> >
> > Here's the relevant section of the
> > manual<
> http://openjpa.apache.org/builds/apache-openjpa-1.2.3-SNAPSHOT/docs/manual/manual.html#ref_guide_detach_graph
> >.
> >
> >
> > In your use case you want to use openjpa.DetachState=loaded. Using 'all'
> or
> > 'fetch-groups' may cause other objects to be loaded when an entity is
> > detached.
> >
> > Hope this helps,
> > -mike
> >
> > On Tue, Feb 1, 2011 at 12:45 AM, 玉米老 <wa...@gmail.com> wrote:
> >
> >> Hello Rick and Mark,
> >> First of all, I appreciate your quick response very much.
> >>
> >> As your advices, I have opened the OpenJPA trace log and tried to
> >> figure out what did it really do when clear() method of Entity Manager
> >> was invoked.
> >>
> >> Please let me introduce my scenario first.
> >> I have two table one is master and another is slave.The slave entity
> >> list is LAZY loaded.
> >> My case is every time I try to get a list of master table entity,
> >> clear() method of Entity Manager will be invoked first to make sure
> >> latest entities will be retrieved. In addition, slave entities seldom
> >> be loaded in my scenario.
> >>
> >> But from trace log I found clear() method always try to load all slave
> >> entities and then detach all master and slave entities. I guest that's
> >> the exact root cause why clear() method is so slow.
> >>
> >> And I found upgrading to 1.2.2 and adding below line into
> >> persistence.xml doesn't really make any improvements.
> >>                         <property name="openjpa.Compatibility"
> >> value="ReloadOnDetach=false, FlushBeforeDetach=false"/>
> >>
> >> Any suggestions?
> >>
> >> Regards,
> >> Yu Wang
> >>
> >> On Tue, Feb 1, 2011 at 12:15 AM, Rick Curtis <cu...@gmail.com>
> wrote:
> >> > Yu -
> >> >
> >> > When you call em.clear(), any idea on how many Entities are in your
> >> > persistence context? Could you provide some sort of pseudo code as to
> the
> >> > scenario that you are running?
> >> >
> >> > Thanks,
> >> > Rick
> >> > On Mon, Jan 31, 2011 at 4:16 AM, 玉米老 <wa...@gmail.com> wrote:
> >> >
> >> >> Hello,
> >> >> I upgraded into 1.2.2 and added below line into persistence.xml but
> it
> >> >> doesn't really work. In fact I found clere() is still time consuming.
> >> >> Any suggestions?
> >> >>  <property name="openjpa.Compatibility"
> >> >>                            value="ReloadOnDetach=false,
> >> >> FlushBeforeDetach=false"/>
> >> >>
> >> >> Regards,
> >> >> Yu Wang
> >> >>
> >> >> On Mon, Jan 31, 2011 at 2:53 PM, 玉米老 <wa...@gmail.com> wrote:
> >> >> > I guess this may be relevant:
> >> >> >
> >> >> > https://issues.apache.org/jira/browse/OPENJPA-1414
> >> >> >
> >> >> > On Mon, Jan 31, 2011 at 1:32 PM, 玉米老 <wa...@gmail.com> wrote:
> >> >> >> sorry, I'm using OpenJPA 1.2.1 not 2.1
> >> >> >>
> >> >> >> On Mon, Jan 31, 2011 at 1:26 PM, 玉米老 <wa...@gmail.com> wrote:
> >> >> >>> Hello experts:
> >> >> >>> I found sometimes invoking clear() method of entity manager will
> >> took
> >> >> >>> more than 30 seconds.
> >> >> >>> I don't know if there' re some performance issues or I shouldn't
> >> >> >>> invoke clear() method first to get updated objects?
> >> >> >>>
> >> >> >>> Regards,
> >> >> >>> Yu Wang
> >> >> >>>
> >> >> >>
> >> >> >
> >> >>
> >> >
> >>
> >
>

Re: OpenJPA 2.1 clear() is very slow.

Posted by 玉米老 <wa...@gmail.com>.
Mike,
You're right, I set : openjpa.DetachState="all".
Thank you very much!

Regards,
Yu Wang

On Tue, Feb 1, 2011 at 10:37 PM, Michael Dick <mi...@gmail.com> wrote:
> Hi,
>
> Do you have any other openjpa properties set in persistence.xml?
> Specifically the openjpa.DetachState property can affect which entities are
> loaded when you clear, or manually detach entities.
>
> Here's the relevant section of the
> manual<http://openjpa.apache.org/builds/apache-openjpa-1.2.3-SNAPSHOT/docs/manual/manual.html#ref_guide_detach_graph>.
>
>
> In your use case you want to use openjpa.DetachState=loaded. Using 'all' or
> 'fetch-groups' may cause other objects to be loaded when an entity is
> detached.
>
> Hope this helps,
> -mike
>
> On Tue, Feb 1, 2011 at 12:45 AM, 玉米老 <wa...@gmail.com> wrote:
>
>> Hello Rick and Mark,
>> First of all, I appreciate your quick response very much.
>>
>> As your advices, I have opened the OpenJPA trace log and tried to
>> figure out what did it really do when clear() method of Entity Manager
>> was invoked.
>>
>> Please let me introduce my scenario first.
>> I have two table one is master and another is slave.The slave entity
>> list is LAZY loaded.
>> My case is every time I try to get a list of master table entity,
>> clear() method of Entity Manager will be invoked first to make sure
>> latest entities will be retrieved. In addition, slave entities seldom
>> be loaded in my scenario.
>>
>> But from trace log I found clear() method always try to load all slave
>> entities and then detach all master and slave entities. I guest that's
>> the exact root cause why clear() method is so slow.
>>
>> And I found upgrading to 1.2.2 and adding below line into
>> persistence.xml doesn't really make any improvements.
>>                         <property name="openjpa.Compatibility"
>> value="ReloadOnDetach=false, FlushBeforeDetach=false"/>
>>
>> Any suggestions?
>>
>> Regards,
>> Yu Wang
>>
>> On Tue, Feb 1, 2011 at 12:15 AM, Rick Curtis <cu...@gmail.com> wrote:
>> > Yu -
>> >
>> > When you call em.clear(), any idea on how many Entities are in your
>> > persistence context? Could you provide some sort of pseudo code as to the
>> > scenario that you are running?
>> >
>> > Thanks,
>> > Rick
>> > On Mon, Jan 31, 2011 at 4:16 AM, 玉米老 <wa...@gmail.com> wrote:
>> >
>> >> Hello,
>> >> I upgraded into 1.2.2 and added below line into persistence.xml but it
>> >> doesn't really work. In fact I found clere() is still time consuming.
>> >> Any suggestions?
>> >>  <property name="openjpa.Compatibility"
>> >>                            value="ReloadOnDetach=false,
>> >> FlushBeforeDetach=false"/>
>> >>
>> >> Regards,
>> >> Yu Wang
>> >>
>> >> On Mon, Jan 31, 2011 at 2:53 PM, 玉米老 <wa...@gmail.com> wrote:
>> >> > I guess this may be relevant:
>> >> >
>> >> > https://issues.apache.org/jira/browse/OPENJPA-1414
>> >> >
>> >> > On Mon, Jan 31, 2011 at 1:32 PM, 玉米老 <wa...@gmail.com> wrote:
>> >> >> sorry, I'm using OpenJPA 1.2.1 not 2.1
>> >> >>
>> >> >> On Mon, Jan 31, 2011 at 1:26 PM, 玉米老 <wa...@gmail.com> wrote:
>> >> >>> Hello experts:
>> >> >>> I found sometimes invoking clear() method of entity manager will
>> took
>> >> >>> more than 30 seconds.
>> >> >>> I don't know if there' re some performance issues or I shouldn't
>> >> >>> invoke clear() method first to get updated objects?
>> >> >>>
>> >> >>> Regards,
>> >> >>> Yu Wang
>> >> >>>
>> >> >>
>> >> >
>> >>
>> >
>>
>

Re: OpenJPA 2.1 clear() is very slow.

Posted by Michael Dick <mi...@gmail.com>.
Hi,

Do you have any other openjpa properties set in persistence.xml?
Specifically the openjpa.DetachState property can affect which entities are
loaded when you clear, or manually detach entities.

Here's the relevant section of the
manual<http://openjpa.apache.org/builds/apache-openjpa-1.2.3-SNAPSHOT/docs/manual/manual.html#ref_guide_detach_graph>.


In your use case you want to use openjpa.DetachState=loaded. Using 'all' or
'fetch-groups' may cause other objects to be loaded when an entity is
detached.

Hope this helps,
-mike

On Tue, Feb 1, 2011 at 12:45 AM, 玉米老 <wa...@gmail.com> wrote:

> Hello Rick and Mark,
> First of all, I appreciate your quick response very much.
>
> As your advices, I have opened the OpenJPA trace log and tried to
> figure out what did it really do when clear() method of Entity Manager
> was invoked.
>
> Please let me introduce my scenario first.
> I have two table one is master and another is slave.The slave entity
> list is LAZY loaded.
> My case is every time I try to get a list of master table entity,
> clear() method of Entity Manager will be invoked first to make sure
> latest entities will be retrieved. In addition, slave entities seldom
> be loaded in my scenario.
>
> But from trace log I found clear() method always try to load all slave
> entities and then detach all master and slave entities. I guest that's
> the exact root cause why clear() method is so slow.
>
> And I found upgrading to 1.2.2 and adding below line into
> persistence.xml doesn't really make any improvements.
>                         <property name="openjpa.Compatibility"
> value="ReloadOnDetach=false, FlushBeforeDetach=false"/>
>
> Any suggestions?
>
> Regards,
> Yu Wang
>
> On Tue, Feb 1, 2011 at 12:15 AM, Rick Curtis <cu...@gmail.com> wrote:
> > Yu -
> >
> > When you call em.clear(), any idea on how many Entities are in your
> > persistence context? Could you provide some sort of pseudo code as to the
> > scenario that you are running?
> >
> > Thanks,
> > Rick
> > On Mon, Jan 31, 2011 at 4:16 AM, 玉米老 <wa...@gmail.com> wrote:
> >
> >> Hello,
> >> I upgraded into 1.2.2 and added below line into persistence.xml but it
> >> doesn't really work. In fact I found clere() is still time consuming.
> >> Any suggestions?
> >>  <property name="openjpa.Compatibility"
> >>                            value="ReloadOnDetach=false,
> >> FlushBeforeDetach=false"/>
> >>
> >> Regards,
> >> Yu Wang
> >>
> >> On Mon, Jan 31, 2011 at 2:53 PM, 玉米老 <wa...@gmail.com> wrote:
> >> > I guess this may be relevant:
> >> >
> >> > https://issues.apache.org/jira/browse/OPENJPA-1414
> >> >
> >> > On Mon, Jan 31, 2011 at 1:32 PM, 玉米老 <wa...@gmail.com> wrote:
> >> >> sorry, I'm using OpenJPA 1.2.1 not 2.1
> >> >>
> >> >> On Mon, Jan 31, 2011 at 1:26 PM, 玉米老 <wa...@gmail.com> wrote:
> >> >>> Hello experts:
> >> >>> I found sometimes invoking clear() method of entity manager will
> took
> >> >>> more than 30 seconds.
> >> >>> I don't know if there' re some performance issues or I shouldn't
> >> >>> invoke clear() method first to get updated objects?
> >> >>>
> >> >>> Regards,
> >> >>> Yu Wang
> >> >>>
> >> >>
> >> >
> >>
> >
>