Hi,
today i ran into a new problem.
I have a n2m relation between to tables.
class DrugCategory <-- n2m --> class Drug
if i obtain one DrugCategory with the EntityManager and want to load
the nested Drug objects to that Category JBoss has a lot of work to do, because there are nealry 10000 of the nested Drug-Objects.
I do Lazy-Loading and want only to get about the first 20 of the nested Drug-Objects.
How can i get this way?
I built a loop like
DrugCategory cat = em.find(DrugCategory.class, catId); Collection <Drug>dc = cat.getDrugs(); Collection <Drug> newDc = new ArrayList<Drug>(); int i = 0; for (Iterator iter = dc.iterator(); iter.hasNext() && (i < 10);i++) { newDc.add((Drug) iter.next()); }
use a collection filter, this is Hibernate specific though