Tag Archives: HQL

Hibernate Performance Tuning Tip: Identifying and Resolving N+1 SELECTs Problem

Problem (in Simple Words) Let’s assume that you’re writing code that’d track the price of mobile phones. Now, let’s say you have a collection of objects representing different Mobile phone vendors (MobileVendor), and each vendor has a collection of objects representing the PhoneModels they offer. To put it simple, there’s exists a one-to-many relationship between […]

Criteria Queries vs HQL in Hibernate

Criteria queries are ideal for dynamic queries. It makes the task of adding ordering, leaving some parts (e.g. restrictions) out depending on some parameter. HQL is ideal for static and complex queries coz it it’s much easier to read/understand HQL. It’s a bit more powerful for join queries. There is a difference in terms of […]