Reputation: 3344
I've got an HQL statement like this:
select new map (f1 as field1, (select ...) as field2)
from ...
where ...
order by field2;
It fails saying "Unknown column 'field2'". I experienced this in general that when using the "new map" statement, I can't reference the map names in the order by field.
As HQL subqueries are only allowed in the select or the where clause, I can't just copy over the subquery to the order by clause either (which wouldn't be so nice anyway).
Am I missing something or do I have to refrain from using a map?
Upvotes: 1
Views: 1256
Reputation: 3344
I found it, it's really a bug (unresolved since five years!) and it doesn't matter whether I use the alias within "new map" or in the conventional way. However there's a workaround that works for me: Just reference the column using col_0_0_
, col_1_0_
etc. This also works with "new map".
See this bug description for more information.
Upvotes: 2