Hi All,
I was wondering why the Criteria API is so restricted at some places. It was such a good idea to create it and it could be used much more flexibly.
Some ideas:
1) It is a pity that the expressions once created cannot be examined at all. There is no getXXX() method for any of the attributes of the Expression subclasses and no access for the expressions stored in the Criteria object.
I could use the Criteria API for completely Hibernate independent purposes (now I have to write something very similar to the Criteria API).
2) It would be nice if I could render HQL WHERE parts with it (this way I could simply render the criteria and include it into the WHERE part of an HQL query). Of course this would raise the issue of separating the rendering functionality from the Expression classes since they currently seem to host the SQL rendering functionality. It would make more sense to create separate renderer classes which would traverse the expression tree and generate something (e.g. one HQLRenderer could render an HQL WHERE clause, an SQLRenderer could render the direct SQL WHERE clause...etc). Of course traversing needs solving problem 1.
Of course, I am aware that the Criteria API was primarily created for simple cases where the user needs to execute a Hibernate query but it could be used much more flexibly.
Andras
|