You are on page 1of 1

HQL: The Hibernate Query Language

Note that these last two queries will require more than one SQL . This means that the clause
does not correctly order the whole result set.

In order to use non-mapped base classes or interfaces in HQL queries, they have to be imported. See Sec-
tion 5.1.23, “import” for more information.

15.7. The where clause


The clause allows you to narrow the list of instances returned.

returns instances of named 'Fritz'.

will return all instances of for which there exists an instance of with a property equal to the
property of the . Compound path expressions make the clause extremely powerful. Con-
sider:

This query translates to an SQL query with a table (inner) join. If you were to write something like

you would end up with a query that would require four table joins in SQL.

The operator may be used to compare not only properties, but also instances:

The special property (lowercase) may be used to reference the unique identifier of an object. (You may also
use its property name.)

The second query is efficient. No table join is required!

Properties of composite identifiers may also be used. Suppose has a composite identifier consisting of
and .

NHibernate 5.2 148

You might also like