I want to make SQL look like:
select b from Book b order by rand()
how convert that query to Querydsl query?
Is it not supported by Querydsl? If you know the way to support this query, please answer it..;
thank you.
Querydsl SQL supports it via
NumberExpression.random()
So your query could be expressed like this
query.from(b)
.orderBy(NumberExpression.random().asc())
.list(b);
I am not sure how well it is supported for JPQL, it doesn't seem to be in the standard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With