2 Replies Latest reply on Aug 3, 2007 7:54 AM by Jaime Martin

    query order by extension and restrictions

    Jaime Martin Apprentice

      hi!
      setting the order of a query result by configuration may be done this way:

      <framework:entity-query name="jmpRstReport4"
      ejbql="select rstReport from RstReport rstReport"
      order="code desc"/>

      I wonder if there is a way of doing the same by extension.
      I have a POJO DAO this way:

      @Name("rstReportList")

      private static final String[] RESTRICTIONS = {
      "lower(rstReport.rstStatus.description) like concat(lower(#{rstReportList.rstReport.rstStatus.description}),'%')",
      "lower(rstReport.rstStatus.description) not like lower(#{'TEMPLATE'})",
      "lower(rstReport.shortDescription) like concat(lower(#{rstReportList.rstReport.shortDescription}),'%')",
      };

      public class RstReportList extends EntityQuery {
      @Override
      public String getEjbql() {
      return "select rstReport from RstReport rstReport";
      }
      }

      Apart from adding "order by code desc" to the ejbql code, how may I set the order by extension?

      On the other hand, if 2 pages need the same query but with different restrictions. the best way would be to define 2 queries, each one with its proper restriction/s, or is there a way to set restrictions dinamycally by means of a parameter or something like that?
      For instance I have a component called "myQuery". Once I want to use it with restriction 1, but in other page I want to use it with restriction 2 and not applying 1. is that possible? Defining 2 queries (each with its restriction) works fine and solves the problem. but is that the best way?

      thanks in advance!