Skip to content

AOT Query escape chars #1833

Closed
Closed

Description

@BoykoAlex

See the following repo class:

@Repository
public interface OfficeRepository extends JpaRepository<Office, Integer> {

    List<Office> findByNameContainingIgnoreCase(String name);

}

The implementation of the method is below. Note the query string:

  /**
   * AOT generated implementation of {@link OfficeRepository#findByNameContainingIgnoreCase(java.lang.String)}.
   */
  public List<Office> findByNameContainingIgnoreCase(String name) {
    String queryString = "SELECT o FROM Office o WHERE UPPER(o.name) LIKE UPPER(:name) ESCAPE '\\'";
    Query query = this.entityManager.createQuery(queryString);
    query.setParameter("name", "%%%s%%".formatted(name != null ? name.toUpperCase() : name));

    return (List<Office>) query.getResultList();
  }

Now if use the CodeLens to add a query annotation the escape char from \\ becomes \. See below:

    @Query("""
            SELECT o
            FROM Office o
            WHERE UPPER(o.name) LIKE UPPER(:name) ESCAPE '\'
            """)
    List<Office> findByNameContainingIgnoreCase(String name);

The produced query is invalid. The app fails to start with this query.

Activity

  1. changed the title [-]AOT Query espace chars[/-] [+]AOT Query escape chars[/+] on Mar 9, 2026
  2. added this to the 5.2.0.RELEASE milestone on Mar 10, 2026
  3. added
    for: eclipse
    for: vscode
    and removed on Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: eclipsefor: vscodetheme: spring-data-supporttype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions