title: Filter CriteriaQuery JPA 2.0
body: <p>I am making an application with Java 1.6, Jsf 2.0, JPA 2.0, Primefaces 5.3 over a WebLogic server 10.3.6</p>
  
  <p>I require to implement the lazy datatables burden for certain modules and I could not make the filter work.</p>
  
  <p>This is the load method:</p>
  
  <pre><code>public List&lt;T&gt; load(int first, int pageSize, String sortField,
      SortOrder sortOrder, Map&lt;String, Object&gt; filters) {
  // TODO Auto-generated method stub
  try {
      List&lt;T&gt; list = new ArrayList&lt;T&gt;();
  
      //Criteria Query
      CriteriaBuilder cb = this.ejbUtils.getEntityManagerPrivate().getCriteriaBuilder();
      CriteriaQuery&lt;T&gt; cq = cb.createQuery(entityClass);
  
      //From
      Root&lt;T&gt; from = cq.from(entityClass);
  
      //Sort
      if(sortField != null){
          if(sortOrder == SortOrder.ASCENDING){
              cq.orderBy(cb.asc(from.get(sortField)));
          }else{
              cq.orderBy(cb.desc(from.get(sortField)));
          }
      }
  
      //Filters
      if(!filters.isEmpty()){
  
          List&lt;Predicate&gt; predicates = new ArrayList&lt;Predicate&gt;();
  
          for (Iterator&lt;String&gt; it = filters.keySet().iterator(); it.hasNext();) {
  
              String filterProperty = it.next();
              Object filterValue = filters.get(filterProperty);                   
              Expression&lt;String&gt; literal = cb.upper(cb.literal((String)filterProperty.toUpperCase()));
  
              predicates.add(cb.like(literal, String.valueOf("%" + filterValue + "%").toUpperCase()));
  
          }               
          cq.where(predicates.toArray(new Predicate[predicates.size()]));             
      }   
  
      Query q = this.ejbUtils.getEntityManagerPrivate().createQuery(cq);
  
      list = q
              .setFirstResult(first)
              .setMaxResults(pageSize)
              .getResultList();
  
      this.setRowCount(this.ejbUtils.count());
  
      return list;
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return null;
    }
  }
  </code></pre>
  
  <p>And I look at the log EclipseLink and throws me this</p>
  
  <p>[EL Fine]: 2016-07-15 11:15:35.415--ServerSession(1294563329)--Connection(1645363733)--Thread(Thread[[ACTIVE] ExecuteThread: '21' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--SELECT * FROM (SELECT /*+ FIRST_ROWS / a., ROWNUM rnum FROM (SELECT ID AS a1, ACTION AS a2, ACTIVA AS a3, FECHA_CREACION AS a4, FECHA_MODIFICACION AS a5, NOMBRE AS a6, USUARIO_CREACION AS a7, USUARIO_MODIFICACION AS a8, ID_PADRE AS a9 FROM SE_OPCIONES WHERE UPPER(?) LIKE ?) a WHERE ROWNUM &lt;= ?) WHERE rnum > ? bind => [NOMBRE, %ROL%, 10, 0]</p>
  
  <p>Then when I enter a filter in the datatable never brings results.</p>