Malformed HQL when QTuple in where clause
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Querydsl |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
I was trying to use QueryDsl to produce the following (working) SQL:
SELECT status.cas_id,
status.
status.
FROM applicstat_apst status
WHERE (status.cas_id, status.status_date) IN
(SELECT s.cas_id,
MAX(
FROM applicstat_apst s
GROUP BY s.cas_id
)
Its purpose is to select the most recent ApplicationStatus, which is a One-To-Many bidirectional list on another entity called CaseRecord, where most recent is not the order of creation, but another Date field called statusDate.
What I came up with is:
List<Tuple> tuples = query()
.from(
.where(
.
.
.list(new QTuple(
.list(new QTuple(
Unfortunately this produces:
class java.lang.
from nz.govt.
where applicationStat
from nz.govt.
group by applicationStat
You can see that in the where clause, the tuple fields are not bracketed in the generated SQL, making it malformed.
FactoryExpressions like the QTuple are only allowed in the projection. I will add better error handling for this.