Nah, your criticism is fine. Its a messy, expedient piece of code. The query
translating code is definitely the least understandable part of Hibernate. I
would have rewritten it all using an ANTLR grammar ages ago, except that the
query language has *not* been a source of bugs and I have always been able
to implement new features surprisingly easily.
As for your question about scalarSelectTokens, scalarTypes, etc: you need to
understand that we are trying to parse two different kinds of queries with
the same code here:
* find() style queries that return entities, with all their properties
* iterate() style queries that return scalar values and ids of entities (and
allow aggregate functions)
Everything is identical for the two types of queries, *except* the SELECT
clause.
The QueryTranslator actually compiles *both* simultaneously (simply ignoring
any scalar values for the find() style query). A bit bizarre, I know ... it
works; thats all I care about at this stage.
So scalarSelectTokens, etc are used for the iterate() style query.
> Hmm I'd needed some explanation (some more commenting could care about it)
about QueryTranslator, and what do we mean by scalarSelectTokens,
scalarTypes and co. Especially the renderSQL() function looked like a bit
messy to me at the first glance.
>
> (Do not take this as plain critics, I'm not supposed to understand any
piece of difficult codes of others at the first look :)
|