I recently discovered that subselect queries cannot be used within case statements according to the HQL grammar, however, this is definitely supported by MySQL, and a cursory search seems to confirm that it is supported in most DB's.
I found a post relating to a similar issue, only with arithmetic combinations of subselect results, which I had also tried to use to work around this issue, and discovered that the author of the post had tracked the problem to the grammar definition in "hql-sql.g" (unfortunately I have been unable to find the original post again).
I modified the grammar file, and changed the case/when and arithmetic parameter types from "expr" to "exprOrSubquery", and recompiled hibernate and can now use subselects within both case statements and arithmetic without issue.
Is this likely to be changed within the source, or is there a compelling reason that I'm unaware of for this choice?
Thanks,
James
|