Ah, I get it, thanks!
Now that I have that sorted out, I would need the result of
from purchased_image pi
left join purchase p on
p.id = pi.purchase_id
where pi.image_id =
i.id and p.valid_to > NOW() and p.user_id = ${userId}) as hasAccess
to be a part of the result (see the first post in this thread). Can this be done with QueryDSL? I have now:
withSQL(select(
i.result.id,
i..., (other fields from image)
select(pi.id).from(PurchasedImage as pi)
.leftJoin(Purchase as p)
.on(pi.purchaseId, p.id)
.where.eq(pi.imageId, i.result.id)
.and
.eq(p.userId, userId)
.and
.ge(p.validTo, ZonedDateTime.now()))
.from(Image as i))
.map(Image(i.resultName))
. list().apply()
But I get "required SQLSyntax, found ConditionSQLBuilder[Nothing]"
I added hasAccess to Image case class property and apply method (there isn't such column in the table).
Can this be done with queryDSL or should it be done some other way?