Get all updates of Java4s
Follow Us: Email Newsletter

Part 2 Hibernate Query Language, Executing HQL Commands

Hibernate » On Jul 8, 2011 { 4 Comments } By Sivateja

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

Syntax:

Notes:

  • 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 Author ♦

Java4s_Author
sivateja@java4s.com
Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

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

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
Upcoming
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

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