Skip to content

Can't be run query SpEL syntax in Micronaut Data Hibernate Reactive #3537

@TDMinhNhat

Description

@TDMinhNhat

Hi everyone, who read this issue, I got this error when I trying to run the query below:

    @Query(value = """
            select t from Tag t
            where (:#{#filter.id} is null or t.id = :#{#filter.id})
            and (:#{#filter.deleted} is null or t.deleted = :#{#filter.deleted})
            and (:#{#filter.createdAt} is null or t.createdAt >= :#{#filter.createdAt})
            and (:#{#filter.updatedAt} is null or t.updatedAt <= :#{#filter.updatedAt})
            and (:#{#filter.code} is null or t.code like %:#{#filter.code}%)
            and (:#{#filter.name} is null or t.name like %:#{#filter.name}%)
            order by t.name asc
        """)
    Mono<Page<Tag>> getAllTagsByFilter(TagQo filter, Pageable pageable);

And my console has printed out the message after running that query:

2025-09-30T10:07:01.505 [WARN] io.vertx.core.impl.BlockedThreadChecker - Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 2566 ms, time limit is 2000 ms
line 2:12 token recognition error at: '#'
2025-09-30T10:07:01.805 [ERROR] io.micronaut.http.server.RouteExecutor - Unexpected error occurred: org.hibernate.query.SyntaxException: At 2:12, token recognition error at: '#' [    select t from Tag t
    where (:#{#filter.id} is null or t.id = :#{#filter.id})
    and (:#{#filter.deleted} is null or t.deleted = :#{#filter.deleted})
    and (:#{#filter.createdAt} is null or t.createdAt >= :#{#filter.createdAt})
    and (:#{#filter.updatedAt} is null or t.updatedAt <= :#{#filter.updatedAt})
    and (:#{#filter.code} is null or t.code like %:#{#filter.code}%)
    and (:#{#filter.name} is null or t.name like %:#{#filter.name}%)
    order by t.name asc
]

Have everybody been here same my issues? I love this syntax it's convenient instead of passing all the parameters into the function, that make the function long line.

Tech: Reactive, Micronaut Data Hibernate Reactive
Database: PostgreSQL

Thanks for reading my issue. Have a good day.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions