Hi all, I have a problem with the scalability of an iteration using Hibernate and Struts.
I have a simple JSP page that has an iteration over a big collection, like:
<logic:iterate id="data" name="eventsCampaignForm" property="events" type="com.domain.event.Eventhistory" indexId="ctr" length="<%=length.toString()%>" offset="<%=offset.toString()%>">
......
<td><%= data.getParty().getPartyname() %></td>
......
</logic:iterate>
The "events" property is a java.util.Iterator object on my form bean. I control the paging to display only 10 rows per page. The problem I have is that every time the JSP page is loaded, Hibernate reads the full set of Eventhistory records, one by one:
Hibernate: select person0_.PURN as PURN52_0_, person0_.FIRSTNAME as FIRSTNAME52_0_, person0_.LASTNAME as LASTNAME52_0_, ... from PERSON person0_ where person0_.PURN=?
Hibernate: select party0_.URN as URN51_0_, party0_.PARTYNAME as PARTYNAME51_0_, ... from PARTY party0_ where party0_.URN=?
.....
This is extremely slow. I think, this started to occur since we upgraded hibernate to the latest version.
What can I do to avoid this?
thanks in advance!
Hibernate version:3
Mapping documents:
<class name="Eventhistory" table="EVENTHISTORY">
....
<many-to-one name="party" column="PARTYID" class="com.domain.party.Party" not-found="ignore"/>
....
</class>
<class name="com.domain.party.Party" table="PARTY">
....
<many-to-one name="person" class="com.domain.party.Person" cascade="all" lazy="false" not-found="ignore" column="PURN"/>
.....
</class>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html