Hello all,
I have a webapp in the works running on
JBoss 4.0.0RC2/MySQL 4.0.20a with HTTP being handled by
struts. I'm allowing users to enter wildcard characters in a form, then passing the argument down to the persistence layer as an ejbql query:
<query>
<description>Flexibly searches for Proteins by name</description>
<query-method>
<method-name>findLikeName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<result-type-mapping>Local</result-type-mapping>
<ejb-ql>
<![CDATA[SELECT Object(o) FROM ProteinEJB AS o where o.name like ?1]]>
</ejb-ql>
</query>
So far, so good...
The problem arises when the size of my search result grows too large, on the order of >100 DTOs returned up the heirarchy to my struts Action. I believe the performance hit comes when I try to iterate through the Collection they are contained within and pull a large number of related objects back out of the persistence layer, as in:
...
Iterator myItr = collection.iterator();
...
while (myItr.hasNext()) addMoadlets( ps.getMoadlets(((ProteinBean.Protein) myItr.next()).getId()));
...
where ps is a stateless Session object and getMoadlets returns a collection of "moadlets" which are related many-to-many with the Protein objects.
The object design must be more-or-less fixed, so the questions are:
1. Can I adopt some sort of limited paging scheme to cut down the original collection size, and if so, how?
2. Are there tuning parameters available to me?
3. Is there a way to short-circuit the problem by performing some pre-filtering of the original query (WHERE clause - many of the filtering attibutes belong to CMR fields of Protein)?
4. Other ideas?