Skip to main content

HQL and JPA Query Language

  • Chapter
  • First Online:
Hibernate Recipes

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).

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 29.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 39.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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. 2.

    As usual, one of your authors far prefers the annotations for named queries; your mileage may vary.

  3. 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. 4.

    In case you’re desperately interested, explicit joins are outer joins just like implicit joins are inner joins.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics