Hibernate Query Langugae (HQL)

Hibernate Query Language:

  • HQL is one of the feature of Hibernate.
  • HQL is same like SQL but here it uses class name as table name and variables as columns.
  • HQL is Database independent query language.
  • An object oriented form of SQL is called HQL
  • HQL syntax is very much similar to SQL syntax.  Hibernate Query Language queries are formed by using Entities and their properties, where as SQL quires are formed by using Tables and their columns.
  • HQL Queries are fully object oriented..
  • HQL Queries are case sensitive.


Advantages of HQL:

  • Database Independent
  • HQL Queries supports inheritance and polymorphism
  • Easy to learn. 

Query Interface:

  • Query interface used to Represent HQL query in the form of query object.
  • The object of  query will be created by calling createQuery(hql query) method of session.

  1.  Session hsession = sf.openSession();
  2. Query query = hsession.createQuery(hql query);

  • Send the query object to hibernate software by calling the list method.
  • Hibernate returns an ArrayList object render the ArrayList object and display the output to client.

  1. List l = query.list();
  2. ArrayList emplist = (ArrayList)l;

  • Query is an interface which is available as port of org.hibernate package. We can not create the object to query interface. We can create a reference variable and it holds implementation class object.

 Methods of Query Interface:

HQL hibernate query language

Advantages and disadvantages of hibernate compared to jdbc

Advantages of Hibernate over JDBC:

  1. Hibernate is an ORM tool
  2. Hibernate is an open source framework.
  3. Better than JBDC.
  4. Hibernate has an exception translator , which converts checked exceptions of JDBC in to unchecked exceptions of hibernate. So all exceptions in hibernate are unchecked exceptions and Because of this no need to handle exceptions explicitly.
  5. Hibernate supports inheritance and polymorphism.
  6. With hibernate we can manage the data stored across multiple tables, by applying relations(association)
  7. Hibernate has its own query language called Hibernate Query Language. With this HQL hibernate became database independent.
  8. Hibernate supports relationships like One-To-One, One-To-Many, Many-To-One ,Many-To-Many.
  9. Hibernate has Caching mechanism. using this number of database hits will be reduced. so performance of an application will be increases.
  10. Hibernate supports lot of databases.
  11. Hibernate supported databases List.
  12. Hibernate is a light weight framework because hibernate uses POJO classes for data transfer between application and database.
  13. Hibernate has versioning and time stamp feature with this we can know how many number of times data is modified.
  14. Hibernate also supports annotations along with XML.
  15. Hibernate supports Lazy loading.
  16. Hibernate is easy to learn it is developers friendly.
  17. The architecture is layered to keep you isolated from having to know the underlying APIs.
  18. Hibernate maintains database connection pool.
  19. Hibernate  has Concurrency support.
  20. Using Hibernate its Easy to maintain and it will increases productivity


Disadvantages of Hibernate Compared to JDBC!!:
  • Hibernate is slow compared to JDBC because of generating many sql queries at run time but this is not considered as dis advantage in my view.
  • Below are some of the dis advantages but these are not applicable to small applications. But we have given some possible scenarios. 

advantages and disadvantages of hibernate

Hibernate supported databases List

  • Hibernate is an ope source framework and also called as an ORM tool.
  • Hibernate supports lot of databases. 
  • Please find below list of databases that are supported by hibernate.
  • Hibernate supported databases list 


  1. DB2    
  2. DB2 AS/400   
  3. DB2 OS390 
  4. FrontBase
  5. Firebird  
  6. HypersonicSQL 
  7. H2 Database  
  8. Informix   
  9. Ingres  
  10. Interbase
  11. MySQL5    
  12. MySQL5 with InnoDB    
  13. MySQL with MyISAM    
  14. Mckoi SQL
  15. Microsoft SQL Server 2000    
  16. Microsoft SQL Server 2005  
  17. Microsoft SQL Server 2008  
  18. Oracle
  19. Oracle 9i   
  20. Oracle 10g    
  21. Oracle 11g      
  22. PostgreSQL  
  23. Progress   
  24. Pointbase
  25. SAP DB
  26. Sybase
  27. Sybase 

  •  Following is the list of various important databases dialects for corresponding database.

hibernate supported databases
Select Menu