howto: parent-child selection-performance?
mars1412 Feb 29, 2008 1:41 PMI have a parent/child relationship between 2 entities: CategoryGroup and Category
Now I am thinking of a way to let the user select an arbitrary number of categories (and later store the selected categories in a subtable of the user)
I'm a newbie and thus having some problems here.
on the gui-side I use rich:tabPanel and show one panel for each CategoryGroup and within the panels I want to show one check-box for each Category:
<rich:tabPanel switchType="client"> <c:forEach items="#{categoryGroupList.resultList}" var="categoryGroup"> <rich:tab label="#{categoryGroup.name}"> <rich:dataGrid value="#{categoryGroup.categories}" var="category" columns="4" elements="12"> <h:selectBooleanCheckbox value="#{registration.selectedCategoryIds[category.id]}" /> #{category.name} </rich:dataGrid> </rich:tab> </c:forEach> </rich:tabPanel>
1) c:each?
I can remember some forum posts, that state, that c:forEach should not be used, and that it has bad performance - so I'd like to replace it.
but since rich:tabPanel needs a rich:tab element in the JSF view, I don't see how I could do that - or what to do instead.
2) performance: initial page rendering
When the page is rendered, categoryGroupList.resultList will select all CategoryGroups. the Category-List on these entites are fetched lazily, which means that I have 1 select plus one select for each CategoryGroup.
what could I do about this?
- I don't want to do eager fetching per default
- I'd like to use some sort of join fetch. But I can't use the following statement on categoryGroupList.resultList, because, it will return all rows of CategoryGroup joined with Category (see fetch construct may not be used in queries called using iterate)
select categoryGroup from CategoryGroup categoryGroup inner join fetch categoryGroup.categories
3) performance: ajax call / page reloading
when I make any ajax call to the server (from other elements on the page), or any validation fails, the categoryGroupList statement will be executed again, but the statement for the Categories will not be called.
can anyone explain please?