QueryDSL: how to select literals as part of SQLSubQuery?

How to implement https://stackoverflow.com >

I understand that

new SQLSubQuery (). from (customer) .where (customer.email.eq (" foo@example.com "))

Models

select the client where customer.email = ' foo@example.com '

but I don’t understand how to select [literal] , for example:

select 1 from customer or select ' foo@example.com ', 0

as required by the above link.

+1
querydsl
source share
1 answer

If you use parameters normally, then using constants should work

 new SQLSubQuery().from(customer) .where(customer.email.eq(" foo@example.com ")) .list(Expressions.constant(" foo@example.com "), Expressions.constant(0)) 

Expressions.constant is here http://www.querydsl.com/static/querydsl/3.2.3/apidocs/com/mysema/query/support/Expressions.html#constant%28T%29

+5
source share

All Articles