Hibernate Interview Questions and Answers

What is criteria API?

Criteria API allows you to build up a query object dynamically. The Criteria Query API lets you build nested, structured query expressions in Java, providing a compile-time syntax-checking that is not possible with a query language like HQL or SQL

Hibernate provided createCriteria() methods to create a Criteria object and Restrictions class for expression .

What is Named SQL Query?

Named query is features of Hibernate, in which queries can store in the mapping file or in an annotation on the class.It can be native SQL queries or HQL.
In mapping file, HQL queries can defined in XML <query>tag, and SQL queries can in <sql-query>tag.

Where getNamedQuery() method uses in Hibernate for named query, thst accept named query names and instantiated Query object from pulled result set.

How can we see hibernate generated SQL on console?

We can see hibernate generated SQL by set "show_sql" Hibernate property to true in the Hibernate configuration file hibernate.cfg.xml.

<property name="show_sql">true</property>  

What’s the difference between load() and get() method in hibernate?

load() methods retrieve data from database with provided identifier and if it doesn’t exist, an exception will throw.

get() methods doesn’t throw error and it will return a null value, if row doesn’t exist for provided identifier.

What’s the difference between save() and saveOrUpdate() methods in hibernate?

session.save() Saves an object to the database. This should not be called for an object that has already been saved to the database.

session.saveOrUpdate() Saves an object to the database, or updates the database if object already exists. This method is slightly less efficient than the save() method since it may need to perform a Select statement to check whether the object already or not.

What are various types of collection supported by Hibernate?

Hibernate support following type of collection:

  • Bag
  • Set
  • List
  • Array
  • Map

Latest Updates


A person is to count 4500 currency notes. Let an denote the number of notes he counts in the nth minute. If a1 = a2 = .... = a10 = 150 and a10 , a11 ,... are in an AP with common difference – 2, then the time taken by him to count all notes is ?

The value of product 6 1/2 * 6 1/4 * 6 1/8 * 6 1/16 * -----∞ upto infinite terms?


What is nohup command in unix?

How do display the 10th, 11th and 12th line of a file in Unix?


The mean of 100 students marks was found to be 40. it was found later that a mark 53 was read as 83. the correct mean is?


The geometric mean of three observations 40, 50 and X is 10, then the value of X is ?

Indian Politics

Who appoints the members of National human rights commission?

The President of India can resign by writing under his hand addressed to?

Under which article of the constitution of India can the President of India refer a matter to the Supreme Court for its opinion?

General Computer Knowledge

The term VPN stands for ?

The transmission control protocol(TCP) is a............ layer protocol ?

Oracle PL/SQL

What is the difference between Procedure and Function?

Define exception and How will you raise an exception in PL/SQL procedure?

What is the advantage of using packages for storing PL/SQL objects?

Fill in the blank

I ________ station before the train arrived.

If I ______ a king, I would help everyone.

Radha___________her daughter for an hour.

Errors Identification

Find out which part of the sentence below has an error and mark the option accourdingly -
Sohan was married in 1990 and have three children.