Get all updates of Java4s

Part 2 Hibernate Query Language, Executing HQL Commands

Let us see, how to execute HQL commands..

Procedure To Execute HQL Command:

  • If we want to execute execute an HQL query on a database, we need to create a query object
  • Query ” is an interface given in org.hibernate package
  • In order to get query object, we need to call createQuery() method in the session Interface
  • Query is an interface, QueryImpl is the implemented class
  • we need to call list method for executing an HQL command on database, it returns java.util.List
  • we need to use java.util.Iterator for iterating the List collection



  • line 1: Getting the Query object
  • line 2: Executing the object content (which is HQL command)
  • line 3: Iterating, then while loop and type cast into our class type that’s it

Next Session HQL part 3

You Might Also Like

  ::. About the Author .::

- Full Stack Java/J2EE & UI Web Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


4 Responses to “Part 2 Hibernate Query Language, Executing HQL Commands”
  1. Neeraj says:

    Full marks to you ..awsome tutorials and wonderful concepts..but please correct the definition of composite key because it can confuse a fresher.

    Cheers!!! Neeraj :)

  2. Swamy says:

    Mr Siva and Team,

    This is Excellent tutorials…..It`s Easy for learning.
    It would be much appreciated if included annotation examples also for all topics.
    As most of the projects using annotations only.

    Thanks…. :-)
    Swamy Nadhan G

  3. vamsi says:

    This is Excellent Tutorials Super Sir

  4. siddu says:

    Mr Siva and Team,

    It would be much better if included examples with jsp


By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Spring-Boot-tutorials Hibernate tutorials Spring tutorials Struts tutorials Servlets tutorials Ajax tutorials Log4j tutorials jQuery tutorials Json tutorials Core Java tutorials Web Services tutorials AngularJs tutorials
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2018 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.