8 Replies Latest reply on Sep 10, 2007 4:41 AM by Jaime Martin

    problem using entityqueries

    Jaime Martin Apprentice

      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"

      If I use it directly from a view xhtml file it works ok. For example
       <rich:dataTable id="RstReportTemplate2"
       rendered="#{not empty RstReportTemplate2.resultList}">

      I want to use it from a POJO. I´ve a POJO that uses this query this way:

      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:
      public class RstReportHome extends EntityHome<RstReport> {
       public void wire() {
       RstReportTemplate repTemp = new RstReportTemplate();

      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,