Abstract
When you use JDBC to access databases, you write SQL statements for the query and update tasks. In such cases, you’re dealing with tables, columns, and joins. When you use Hibernate, most update tasks can be accomplished through the provided APIs. However, you still need to use a query language for the query tasks, and Hibernate provides a powerful query language called Hibernate Query Language (HQL).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
You can define queries in annotations and in XML files. Because the query annotations are package-level, you can centralize them in a package-info.java as well (see http://docs.oracle.com/javase/specs/jls/se8/html/jls-7.html#jls-7.4.1 for more information).
- 2.
As usual, one of your authors far prefers the annotations for named queries; your mileage may vary.
- 3.
Note that with the exception of Java class names and properties, queries are not case-sensitive; SeLeCt is the same as select or SELECT. Go nuts. Nobody will care except obsessive-compulsive programmers—and they’ll probably care a lot.
- 4.
In case you’re desperately interested, explicit joins are outer joins just like implicit joins are inner joins.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2015 Joseph Ottinger
About this chapter
Cite this chapter
Ottinger, J., Guruzu, S., Mak, G. (2015). HQL and JPA Query Language. In: Hibernate Recipes. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0127-5_8
Download citation
DOI: https://doi.org/10.1007/978-1-4842-0127-5_8
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-0128-2
Online ISBN: 978-1-4842-0127-5
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)