'Cannot use Pageable in EntityManager.createSelect() method

I have created a gateway application with mysql 8.0.25 using jhipster 7.1.0. I want to make 1 query to get all userExam by user_id, so i used.

Flux findAllBy(Pageable pageable, Criteria criteria)

method which is built-in method in UserExamRepository.

and I used like this.

userExamRepository.findAllBy(pageable, Criteria.where("user_id").is(userId))

But I got this error

nested exception is io.r2dbc.spi.R2dbcBadGrammarException: 

[1064] [42000] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE e.user_id = '4c

with query string

> .... LIMIT 0, 20  WHERE e.user_id =
> '4c973896-5761-41fc-8217-07c5d13a004b

the correct syntax should be

... WHERE... LIMIT 0, 20

this is beacause in this method put the where clause after limit keyword.How can I interchangeable this.

 if (pageable != null) {
        if (criteria != null) {//want to put limitOffest after where clause in createSelectImpl

            return createSelectImpl(
                selectFrom.limitOffset(pageable.getPageSize(), pageable.getOffset()).where(Conditions.just(criteria.toString())),    
                entityType,
                pageable.getSort()
            );
        } else {
            return createSelectImpl(
                selectFrom.limitOffset(pageable.getPageSize(), pageable.getOffset()),
                entityType,
                pageable.getSort()
            );
        }
    } else {
        if (criteria != null) {
            return createSelectImpl(selectFrom.where(Conditions.just(criteria.toString())), entityType, null);
        } else {
            return createSelectImpl(selectFrom, entityType, null);
        }
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source