Hi Rick,

 

I did run some tests  to do as you suggest and do a select count(*) to
negate the need to keep track of the vector size, however my problem with
this is that I have to run a separate query to do this "On demand"  vector
size retrieval. Since my backing bean has Request scope I will need to
instantiate an EM in order to perform the query, this will cause OpenJPA to
retrieve  metadata which is a major performance hit,  secondly if my
dataline entity is complex (which it is) unless  I set up a fetch group I'll
end up executing a very complex execution plan.. all of this because I want
to know how many items there are in a vector.

 

Anyway, this dumb work around stopped my customers screaming so I guess it's
"solution" .

 

Chris

 

 

From: Rick Curtis [mailto:[email protected]] 
Sent: Friday, 30 April 2010 4:06 AM
To: [email protected]; [email protected]
Subject: Re: LazyLoading hell resolved

 

Interesting problem. Unfortunately it looks like your best option is to do
what you are currently doing by keeping track of the size via a field or
another option would be to have a method which will execute a select count
statement to get the size of the list.

I'm not sure if you've looked at large result sets[1] in the past but they
can be helpful when working with very large amounts of data.

[1]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_db
setup_lrs

-- 
Thanks,
Rick

On Thu, Apr 29, 2010 at 11:19 AM, C N Davies <[email protected]> wrote:

Finally I managed to sort out one of my major performance issues with
OpenJPA, but to do so I feel like I'm sacrificing good design.

 

I have a simple Entity:

 

public class LoadHeader ...{

 

@ManyToOne(fetch=FetchType.LAZY)

 private List<dataline> data;

 

public int getData(){

                return data;

}

 

 

If I put in my jsf page;

 

 

<h:outputtext value="#{loadHdrBean.data.size}"/>

 

OpenJPA will load my "data" vector so it can calculate the size of the list.
I can see why it might work this way but since this LoadHeader instance
might contain 100,000 items of complex entities,  just accessing the size of
the vector causes the list to load  taking 2+ minutes.  Removing the
reference to the vector "size"  method allows lazy loading to work just
fine, so I ended up adding a new "int dataCount" member to my LoadHeader.
>From a design perspective this is quite poor because I have to ensure that I
keep the "dataCount" member synchronised with the "size" of the actual
vector.

 

Is this really how I am supposed to be designing my app with OpenJPA?

 

Chris

 

 

 

Regards

 

Neil Davies

 

Error! Filename not specified.

 

Mobile:  +61 403 655872

Email:  [email protected]

 

 

Reply via email to