EJB finder method returns only 25 rows of data in WebSphere Application Server 4.0.x
 Technote (FAQ)
 
Problem
In WebSphere® 4.0.x, a CMP generated EJB™ finder method returns multiple rows of data based on the passed key. However, only the first 25 rows of data are returned when more than 25 rows should be returned.
 
Cause
The EJB container gets either a greedy or lazy version of the enumerator when the finder runs.

For a lazy enumeration, only the first 25 items are retrieved, and if things go normally and you need an item from the next set of 25 (and every subsequent set up to the maximum number of items returned), the hasMoreElements() method triggers a set of calls that gets the next set of 25. However, if the calling transaction ends before the end of the first set of 25, or before any following set of 25 is retrieved, the remainder is not available to you.

For a greedy enumerator, there is a construct that gets all the items, and does not limit the fetch size. If the transaction is created in the finder method's scope (for example, during the bean method's preInvoke processing), a greedy enumerator should be returned; otherwise, it is a lazy enumerator.

If only 25 items are returned, it is because the lazy enumerator is returned.

 
Solution
A greedy enumerator must be used to get more than 25 items. The transaction attribute of the finder method must be set so that a new transaction starts. The TX_REQUIRES_NEW transaction attribute causes this to occur.
 
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > EJB Container
Operating system(s): HP-UX
Software version: 4.0
Software edition:
Reference #: 1117189
IBM Group: Software Group
Modified date: Aug 30, 2004