Posts

Showing posts from April, 2016

Hibernate 'hql' does not support UNION - Hibernate

So in this case run each query individually using 'HQL' and then add the results to a HashSet

Criteria - Hibernate

In Hibernate, the Criteria API helps us build criteria query objects dynamically. Criteria is a another technique of data retrieval apart from HQL and native SQL queries. The primary advantage of the Criteria API is that it is intuitively designed to manipulate data without using any hard-coded SQL statements. Programmatic behavior offers compile-time syntax checking; as a result, most error messages are delivered during compilation. Although it's convenient, this does not provide any performance enhancing ability over HQL or native SQL queries. In fact, it's a preference given to developers to choose according to taste and necessity. You may use all three or stick to one. Let's see if we can find some examples to appreciate the Criteria Query API. Getting Started The  org.hibernate.Criteria  interface defines several methods for creating query objects programmatically. We generally use a  Session  object to call the  createCriteria()  method and crea...