Amateurs study generics and professionals study specifics. Until now, I have been discussing the generics of Hibernate. Now, it's time to understand the specifics. Unless each aspect of Hibernate is understood, it will become really difficult to unleash its full power.
In itself, SQL is very powerful. So when the power of SQL is combined with the flexibility of the object oriented approach, what we get is Hibernate Query Language, or HQL for short. Just like SQL, HQL also provides Projection queries, Aggregation functions, Grouping and Restrictions. Even the most complex queries in SQL can be mapped to HQL.
The first section of this article will detail the usage of HQL on simple queries without any participating relationships. The complexity comes into play when associations occur. In the second section, I will be discussing how to work with HQL in the context of associations. The example in the third section will implement a report using a complex query with a participating relationship. So let's begin.