Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1201

getSearchPredicates should use case insensitive search

    Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.4.0.Final
    • Fix Version/s: 2.1.0.Final
    • Component/s: None
    • Labels:
      None

      Description

      Hi,

      When you do JSF scaffolding, the generated code for research is as follow :

          private Predicate[] getSearchPredicates(Root<Talk> root) {
       
              CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
              List<Predicate> predicatesList = new ArrayList<>();
       
              String title = this.example.getTitle();
              if (title != null && !"".equals(title)) {
                  predicatesList.add(builder.like(root.<String>get("title"), '%' + title + '%'));
              }
      

      The problem with that is the search is case sensitive and searching for "java" or "Java" doesn't bring the same results. It would be more natural to have case insensitive search as follow :

          private Predicate[] getSearchPredicates(Root<Talk> root) {
       
              CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
              List<Predicate> predicatesList = new ArrayList<>();
       
              String title = this.example.getTitle();
              if (title != null && !"".equals(title)) {
                  predicatesList.add(builder.like(builder.lower(root.<String>get("title")), "%" + title.toLowerCase() + "%"));
              }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                agoncal Antonio Goncalves
                Reporter:
                agoncal Antonio Goncalves
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: