Uploaded image for project: 'Spring Data JPA'
  1. Spring Data JPA
  2. DATAJPA-1534

Wildcard character needs to be escaped in Spring data JPA

    XMLWordPrintable

    Details

    • Sprint:
      Moore RC1

      Description

      Queries using org.springframework.data.domain.ExampleMatcher(contains, etc) return more results than anticipated when wildcard (%,_,etc) is supplied because wildcard char were not escaped in spring data ExampleMatcher.

       

       

      String queryString = "myname_";
      ExampleEntity exampleEntity= new ExampleEntity();
      exampleEntity.setFieldName(queryString);
            ExampleMatcher matcher =          ExampleMatcher.matching().withMatcher("fieldname", contains().ignoreCase());
            repository.findAll(Example.of(exampleEntity, matcher), pageable);
      

       

       

            Expected result : Should return the field names which contains myname_
            Actual Result : But it Returns the field names which contains myname followed by any char
            Example : myname1, myname2, myname3 also returned which is unexpected

       

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              schauder Jens Schauder
              Reporter:
              thaveethu-vignesh thaveethu-vignesh
              Last updater:
              Jens Schauder
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: