When using the iBATIS N+1 solution and the max parameter in queryForList, the behavior is a little bit different than what I would expect.

The max parameter appears to only address the total rows returned, however and not the number of elements that would be populated into the return List.

E.g.

I have a table:

products (
  id
  name
)

product_attributes (
  prod_id,
  name,
  value
)

With a query like:

select p.id, p.name, a.name, a.value
from products p, product_attributes a

If there are 30 attributes to a single product and I specify the max results to only be 15, I don't get 15 product objects in my List, but rather a single product object with 15 attributes populated.

This behavior is quite misleading as I would expect to retrieve 15 product objects. Is there any workaround to this? Does anything depend on the existing behavior? Can it be changed to support my desired behavior?

Reply via email to