problem using entityqueries
jamesjmp Sep 6, 2007 12:30 PMhello,
This issue is somehow strange, so I provide you with the related code to make my explanation clear.
I´ve defined this entity-query in my components.xml file.
<framework:entity-query name="RstReportTemplate2" ejbql="select rstReport from RstReport rstReport" order="code"> </framework:entity-query>
If I use it directly from a view xhtml file it works ok. For example
</rich:dataTable> <rich:dataTable id="RstReportTemplate2" var="rstReport" value="#{RstReportTemplate2.resultList}" rendered="#{not empty RstReportTemplate2.resultList}"> <h:column> #{rstReport.code} </h:column> </rich:dataTable>
I want to use it from a POJO. I´ve a POJO that uses this query this way:
@Name("RstReportTemp") public class RstReportTemplate { @In("#{RstReportTemplate2.resultList}") List<RstReport> rstRepTemplates; public RstReportTemplate() { } public void processTemplate() { Iterator<RstReport> rstReportTemp = rstRepTemplates.iterator(); if (rstRepTemplates != null) { while (rstReportTemp.hasNext()) { // business logic code } }else { System.out.println("THERE ARE --NO-- RECORDS MATCHING RstReportTemplate2"); } } }
When invoking to this POJO from a pojoview.page.xml with an action it works fine
<action execute="#{RstReportTemp.processTemplate}"/>
Now, here is my problem. I want to invoke that method, RstReportTemp.processTemplate, from the wire method of a POJOHome.
I´m doing it this way:
@Name("rstReportHome") public class RstReportHome extends EntityHome<RstReport> { public void wire() { ... RstReportTemplate repTemp = new RstReportTemplate(); repTemp.processTemplate(rep); .. } ...}
This time the query doesn´t return any value, in fact the resulting List rstRepTemplates is null.
I don´t understand why the same query (with no restrictions) works fine when used directly from a view or from a POJO which is invoked by an execute of a .page.xml, but doesn´t behave the same way when it is used from a POJO which has been invoked from a different POJO.
I don´t want to have my business logic code in the POJOHome java class, that´s why I´m using another one and invoking from the wire method.
thanks in advance,
Jaime