spring-projects / spring-data-jpa

Simplifies the development of creating a JPA-based data access layer.
https://spring.io/projects/spring-data-jpa/
Apache License 2.0
2.98k stars 1.41k forks source link

QueryDSL generating wrong SQL query [DATAJPA-1216] #1553

Closed spring-projects-issues closed 6 years ago

spring-projects-issues commented 6 years ago

Manish opened DATAJPA-1216 and commented

I have a complicated data model with which I use QueryDSL regularly. However, one of the cases is failing because of an invalid SQL query being generated. I have been unable to determine if it is Spring Data, QueryDSL or Hibernate that is generating the invalid query.

A sample project is available on Github demonstrating the problem. The problem is triggered by the following code:

    @Entity
    @QueryEntity
    class Person {
      private String firstName;
      private String lastName;
      private String middleName;
    }

    QPerson person = QPerson.person;

    BooleanExpression query = person.firstName.concat(" ")
                                   .concat(person.middleName.concat(" ").coalesce(""))
                                   .concat(person.lastName)
                                   .containsIgnoreCase(name);

This kind of a query works in some cases but doesn't in others. In the sample project, PersonRepositoryTest passes with this query, but QuotationRepositoryTest fails due to an invalid SQL query with the same QueryDSL code


Affects: 1.11.8 (Ingalls SR8)

Reference URL: https://github.com/manish-in-java/spring-jpa-querydsl-bug

spring-projects-issues commented 6 years ago

Manish commented

Found an old report of the problem on the QueryDSL forums. Seems like a problem with QueryDSL. Please feel free to close this JIRA