I'm using JBoss 3.0.7 together with XDoclet.
I'm using the value object pattern.
I have this 1 entity bean (CountryBean) with a composite key (CODE and LANGUAGE).
I do a findAll() to get them all and then I loop through the collection, to transform each bean in a value object.
Executing this took for ages.
When I debuged it, I noticed that the method getCountryValue() generated SQL, and lots of it.
In fact , the first Country it tries to transform into ValueObject, this is generated:
SELECT * FROM Country WHERE (CODE=? AND LANGUAGE=?) OR (CODE=? AND LANGUAGE=?) OR (CODE=? AND LANGUAGE=?) OR ...
with as many conditions as there are countries.
Looping through the collection, the number of generated conditions decreases.
When it comes to the last country, only 1 condition is generated.
SELECT * FROM Country WHERE (CODE=? AND LANGUAGE=?)
Anybody an idea as to why it generates the bunch of conditions, in stead of just the 1 (as it does for the last Country, and as it should do I think)?
And anybody an idea as to how to solve this?
If needed I can post the sources.
This is the default read-ahead strategy (on-load). Refer to the CMP documentation to find out how to configure different strategies. Also make sure you're looping your collection within the same transaction.