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

Indian Geography

What is the approximate distance between earth and the moon?

Indian History

In which year was the battle of ‘Koregaon Bhima’ fought?

The approach that is very useful in organizing the content in history is.

General Knowledge of India

NITI Aayog stands for _____.

General Knowledge of MP

India’s first Ramayan art museum was established at?

Errors Identification

Read the sentence carefully and choose the option that has an error in it:
The management’s trusted employee was suspected of stealing large sum of money.

Read the sentence carefully and choose the option that has an error in it:
The teacher asked the child to repeat again because he spoke feebly.

Fill in the blank

Fill in the blank with the most appropriate preposition in the given sentence.
Let’s sit _________ the shade of this beautiful tree.

Choose the most appropriate determiner for the given sentence.
________of what he said was very sensible.


Choose the option that substitutes the given phrase appropriately.
A work of art made by carving

Correct sentence

Choose the option that best transforms the sentence into its Indirect form:
‘What country do you come from?’ said the police officer.

Alternative Phrase

Choose the option that best explains the highlighted expression:
All human beings have feet of clay.

Fill in the blank

Choose an appropriate modal for the given sentence:
My doctor said that I_____ stop smoking as one of my lungs got infected.

Choose the appropriate prepositions for the given sentence:
My parents have been married ________ forty-nine years, but you can still see the love ________ their eyes.

Choose the appropriate conjunction for the given sentence:
______ it rains, the college will declare the holiday.


Choose the appropriate antonym for the highlighted word in the given sentence.
The family protracted their visit by several days.


Choose the appropriate tenses to fill in the blanks in the given sentence:
Please _________ a noise. Ritu __________ to sleep.


Choose the appropriate synonym for the highlighted word in the given sentence.
Does he really expect us to believe such a flimsy excuse?