In 'Hibernate in Action', paragraph 7.5.1 "Dynamic queries", it is discussed how to build dynamic queries.
Firstly, a HQL example with some String concatenation is shown and is it stated that this code is 'tedious and noisy' (which is my opinion too). In the following, better approaches are explained, all building upon the Criteria API.
My question is: I have learned, that the Criteria API is only experimental and has some serious drawbacks in comparison to HQL. What is the best way to build dynamic queries?
I really like the Criteria API. In my opinion, this is the way how object oriented applications should work with RDBMS queries. Due to the drawbacks, I can't use it and would like to now, if there is a way to avoid the StringBuffer operations.
|