openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <...@cndavies.com>
Subject LazyLoading hell resolved
Date Thu, 29 Apr 2010 16:19:44 GMT
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

 

CN_Davies_logo

 

Mobile:  +61 403 655872

Email:  cnd@cndavies.com

 

 


Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message