1 Reply Latest reply on Sep 7, 2011 6:58 PM by nathan dennis

    how to override the EntityQuery class

    Saravanan Vijaya Manoharan Newbie
      when i try to create a EJB-QL following using the class

      ------------------------------------------------------------------------------------------------------
      public class ProjectList extends EntityQuery<Project> {

              private static final long serialVersionUID = -7673337640345325071L;

              private static final String EJBQL = "select project from Project project WHERE userid = #{authenticator.nam}";
              private static final String[] restrictions = {"lower(project.userid) = #{authenticator.nam}"};
              private static final String[] RESTRICTIONS = {
                               "lower(project.processOwner) like lower(concat('%',#{projectList.project.processOwner},'%'))",
                               "lower(project.projectName) like lower(concat('%',#{projectList.project.projectName},'%'))",
                       "project.processDate >= #{projectList.project1.processDate}",
                       "project.processDate <= #{projectList.project1.toDate}",
                       };
              private Project project = new Project();
              private Project1 project1 = new Project1();

              public ProjectList() {
                      setEjbql(EJBQL);
                      setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
                      setMaxResults(25);
              }
              public Project getProject() {
                      return project;
              }
              public Project1 getProject1() {
                      return project1;
              }      
      }
      ----------------------------------------------------------------------------------------------------

      and when ever i apply the logical restriction operator 'OR' the WHERE clause of the resultant query uses OR in between each of the restrictions including the first clause.

      do we have ways to generate a query like

      SELECT project FROM Project project WHERE userid= el1 AND RESTRICTION[1] OR RESTRICTION[2]