In addition, HQL supports many other SQL statement and aggregate functions, such as sum and max and clauses, such as group by and order by. Return results as objects. In other words, the query results are in the form of objects rather than the plain text. These objects can be used to manipulate or retrieve data in an application. This eliminates the need of explicitly creating objects and populating the data from the resultset retrieved from the execution of a query.
Supports polymorphic queries. Polymorphic queries return the query results along with all the child objects objects of subclasses , if any. Easy to learn and use. It is also supports projections, aggregation max, avg , grouping, ordering, sub queries, and SQL function calls. Provides database independency.
That is. Previous Next. Share a word. About the Author: chandrashekhar. Founder of onlinetutorialspoint. Previous Page Print Page. Save Close. Dashboard Logout. Query setFirstResult int startPosition This method takes an integer that represents the first row in your result set, starting with row 0.
HQL is an abbreviation for hibernate query language. Hibernate is a platform to connect the traditional databases to object-oriented language specifically JAVA. It can be called as an object-oriented language embossed with SQL query statements. It is a flexible and user-friendly language having its own syntax and grammar to retrieve, store, update information from the database.
As the importance of JAVA as a language for platforms like the internet is increasing, we find more it relevant to connect our JAVA based application to back end with the help of hibernate. Hibernate uses HQL language instead to establish the connection between database and front-end. We need HQL when we want to select some particular fields and columns as per our requirements.
Methods adopted earlier were not efficient enough to drill down to this level for example fetching the result set or data set from the database as a whole record having the number of rows and columns. This approach does not give the flexibility to narrow down the search and makes the application heavy and sluggish. Using HQL reduces this time gap and provides specific results. Hence It is more relevant to be used in a real-time environment where JAVA is involved in the front end.
The SQL queries which we fire in the database directly using sql queries can be written in hql as well.
0コメント