0% found this document useful (0 votes)
76 views

Chapter 15. HQL: The Hibernate Query Language: 15.1. Case Sensitivity

HQL is Hibernate's query language that allows object-oriented queries while looking similar to SQL. It understands concepts like inheritance, polymorphism, and associations. Case is ignored in queries except for class and property names. The from clause is used to specify the class or alias being queried, and aliases can represent associated entities or collection elements joined using a join. It is considered best practice to name aliases with initial lowercase like local variables.

Uploaded by

nipam1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Chapter 15. HQL: The Hibernate Query Language: 15.1. Case Sensitivity

HQL is Hibernate's query language that allows object-oriented queries while looking similar to SQL. It understands concepts like inheritance, polymorphism, and associations. Case is ignored in queries except for class and property names. The from clause is used to specify the class or alias being queried, and aliases can represent associated entities or collection elements joined using a join. It is considered best practice to name aliases with initial lowercase like local variables.

Uploaded by

nipam1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Chapter 15.

HQL: The Hibernate Query Language


NHibernate is equipped with an extremely powerful query language that (quite intentionally) looks very much
like SQL. But don't be fooled by the syntax; HQL is fully object-oriented, understanding notions like inherit-
ance, polymorphism and association.

15.1. Case Sensitivity


Queries are case-insensitive, except for names of .NET classes and properties. So is the same as
is the same as but is not and is not .

This manual uses lowercase HQL keywords. Some users find queries with uppercase keywords more readable,
but we find this convention ugly when embedded in C# code.

15.2. The from clause


The simplest possible NHibernate query is of the form:

which simply returns all instances of the class .

Most of the time, you will need to assign an alias, since you will want to refer to the in other parts of the
query.

This query assigns the alias to instances, so we could use that alias later in the query. The keyword
is optional; we could also write:

Multiple classes may appear, resulting in a cartesian product or "cross" join.

It is considered good practice to name query aliases using an initial lowercase, consistent with naming stand-
ards for local variables (eg. ).

15.3. Associations and joins


We may also assign aliases to associated entities, or even to elements of a collection of values, using a .

NHibernate 5.2 145

You might also like