-
1. Re: Entity Query is getting fired twice
lvdberg Jun 12, 2009 11:53 AM (in response to narinkalra)Hi,
I cant't help you if you don't give any code, so just the piece of the page (not complete, just the attributes) and the Query you have.
Leo
-
2. Re: Entity Query is getting fired twice
narinkalra Jun 12, 2009 12:06 PM (in response to narinkalra)Hi Leo,
Following is some of the code i am using in my xhtml page, I have mapped the value attribute to my commonListManager class which returns the dataModel to the table
XHTML code
<rich:dataTable var="ecEntity" binding="#{commonListManager.dataTable}" id="ecdt" onRowClick="onRowClick(this);" onRowDblClick="onRowDblClick(this);" value="#{commonListManager.pagedDataModel}" rows="30">
<rich:column id="pur2" style="width:150px;">
<f:facet id="pur2_ecfchdr" name="header">
<span id="pur2_echdrtxt" align="left" style="width:150px;text-align:left;">Purchase Order</span>
</f:facet>
<h:outputText value="#{ecEntity.purCode}"/>
</rich:column>
</richdataTable>
Following is the method of my java class which is mapped to data table
public DataModel getPagedDataModel(){
ECEntityQueryManager ecEntityQueryManager = new ECEntityQueryManager();
log.info("First Row is: " + dataTable.getFirst());
log.info("Rows to fetch: " + dataTable.getRows());
List pagedList = ecEntityQueryManager.getPaginatedResultSet(dataTable.getFirst(), dataTable.getRows());
log.info("Size of the pagedList is: " + pagedList.size());
//Get the total number of records in the entity
int totalCount = ecEntityQueryManager.getResultCount().intValue();
log.info("Total Number of records in the entity: " + totalCount);
ECListDataModel dataModel = new ECListDataModel(pagedList, totalCount, dataTable.getRows());
return dataModel;
}
Following is the method i have written in my EntityQuery class:
public List getPaginatedResultSet(Integer firstResult, Integer maxResult){
setMaxResults(maxResult);
setFirstResult(firstResult);
return getResultList();
}
Hope this will help you understand the structure i am using.
Thanks,
Narin -
3. Re: Entity Query is getting fired twice
lvdberg Jun 12, 2009 12:26 PM (in response to narinkalra)Well,
Maybe you should use the default behaviour of the Seam EntityQuery class? It is not very clear why you create an ECEntityQuerymanager because an EntitManager is automatically available through injection (@In)
Any
standard
combination of Rich:Datatable/scroller and the SeamQuery component works out of the box, paginating the results and proving the DataModel thought Seam @dataModel annotation. So basically I don't see a reason to write your own components to do that.look into the examples directory of your Seam distribution.
Leo
-
4. Re: Entity Query is getting fired twice
pgmjsd Jun 12, 2009 1:26 PM (in response to narinkalra)I think Leo is right. IIRC the SeamQuery components have getters that return cached result lists. I'd have to look at my code to be sure, but if that's the case, then the problem is simple: your getter is doing the query every time and it's called more than once by the page.
-
5. Re: Entity Query is getting fired twice
narinkalra Jun 12, 2009 3:17 PM (in response to narinkalra)Actually, as per my understanding problem is not with the dataModel class, but its dataScroller which is making query to execute again.
Thanks,
Narin