title: How to search with multiple filter using criteria builder
body: <p>I would like to make a multiple filter in java, I use Spring Boot. And my query are written using criteria.</p>
  
  <p>SearchApp.java:</p>
  
  <pre><code>@Entity
  @Table(name = "searchapp")
  public class SearchApp implements Serializable {
  
  @Column(name = "code")
  private String code;
  @Column(name = "release")
  private String release;
  @Column(name = "environnement")
  private String environnement;
  @Column(name = "date")
  private Date date;
  private static final long serialVersionUID = -1701849052760947052L;
  
  public SearchApp() {
      super();
      // TODO Auto-generated constructor stub
  }
  public DeploiementApp(String code, String release, String environnement, Date date) {
      super();
      this.code = code.toLowerCase();
      this.release = release;
      this.environnement = environnement;
      this.date= date;    
  }
  </code></pre>
  
  <p>I have a search controller, which is the door to enter my application</p>
  
  <p>SearchController.java:</p>
  
  <pre><code>@Autowired
  SearchService searchService;
  
  @GetMapping("/filtersearch")
  public List&lt;SearchApp&gt; filter(@RequestParam("code") String code, @RequestParam("release") String release, @RequestParam("environnement") String environnement, @RequestParam("date") String date) {
  
      return searchService.filter(code.toUpperCase(), release.toUpperCase(), environnement.toUpperCase(), date);
  }
  </code></pre>
  
  <p>SearchService.java :</p>
  
  <pre><code>List&lt;SearchApp&gt; filter(String code, String environnement, String release, String date);
  </code></pre>
  
  <p>SearchServiceImpl.java :</p>
  
  <pre><code>@PersistenceContext(type = PersistenceContextType.EXTENDED)
  private EntityManager em;
  
  public SearchServiceImpl(EntityManager em) {
      super();
      this.em = em;
  }
  
  @Override
  public List&lt;SearchApp&gt; filter(String code, String release, String environnement, String date) {
  
  
      DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
      format.setTimeZone(TimeZone.getTimeZone("Europe/Paris"));
      Date dateBD = new Date();
           dateBD = format.parse(date);
      } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
      //select
      CriteriaQuery&lt;SearchApp&gt; criteriaQuery = criteriaBuilder.createQuery(SearchApp.class);
      //from
      Root&lt;SearchApp&gt; itemRoot = criteriaQuery.from(SearchApp.class);
      // attribut
  
      List&lt;Predicate&gt; predicate = new ArrayList&lt;Predicate&gt;();
  
      if(  code != "" || code != null) {
          Predicate predicateCode = criteriaBuilder.equal(itemRoot.get("code"), code);
          predicate.add(predicateCode);
      }
  
      if(  release != "" || release != null) {
          Predicate predicateRelease = criteriaBuilder.equal(itemRoot.get("release"), release);
          predicate.add(predicateRelease);
      }
  
      if(  environnement != "" || environnement != null) {
          Predicate predicateEnvironnement = criteriaBuilder.equal(itemRoot.get("environnement"), environnement);
          predicate.add(predicateEnvironnement);
      }
  
      if(  dateBD != null ) {
          Predicate predicateDate = criteriaBuilder.equal(itemRoot.get("date"), date);
          predicate.add(predicateDate);
      }
  
      Predicate And = criteriaBuilder.and(predicate.toArray(new Predicate[predicate.size()]));
  
      //where
      criteriaQuery.where(And);
      List&lt;SearchApp&gt; result = em.createQuery(criteriaQuery).getResultList();
  
      return result;
  }
  </code></pre>
  
  <p>It does not work. </p>
  
  <p>error: org.hibernate.query.criteria.internal.predicate.ComparisonPredicate@41f4f353
         org.hibernate.query.criteria.internal.predicate.ComparisonPredicate@77ef22f7
  also date errors</p>