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

Simple Interest

The rate of simple interest on a sum of money is 6 percent per annum for first 3 years, 8 percent per annum for the next 5 years and 10 percent per annum for period beyond 8 years. If simple interest accrued by the sum for a total period of 10 years is Rs 1560, What is the sum?

Percentage

Shirin went to a bakery and bought items worth Rs 25, out of which 30 paise went on sales tax on taxable purchases. If the tax rate was 6%, then what was the cost of the tax free items?

Blood Relation

Pointing to a photograph, a man said, "I have no brother or sister but that man’s father is my father’s son." Whose photograph was it?

Introducing a man to her husband, a woman said "His brother's father is the only son of my grandfather". How is the woman related to the man ?

Apache Tomcat

What is the difference between Apache Tomcat server and Apache web server?

MS-DOS

What is the full form of DOS?

Explain the use of help DOS Command?

How we can create a directory in DOS?

Analogy

Riddle:Solve

Limp:Walk

Molecule:Atoms

Misfortune:Catastrophe

Pipes and Cistern

A tank can be filled by one tap in 10 minutes and by another in 30 minutes. Both the taps are kept open for 5 minutes and then the first one is shut off. In how many minutes more is the tank completely filled?

Simplification

Assume that a sum of money is divided equally among n girls. Each girl will receive $60. If another girl is added to the group and the sum is divided equally among all the girls, each child girl gets a $50 share. What is the sum of money?

Problems on Trains

A 300 meter long metro train crosses a platform in a metro station in 39 seconds while it crosses a lamp post in 18 seconds. What is the length of the platform?

Problems on Ages

In a group of 7 people, the average age is found to be 17 years. Two more people joined with an average age 19 years. One person left the group whose age was 25 years. What is the new average age of the group?

Profit and Loss

Irvin sold a book at a profit of 12%. If Irvin had sold it for Rs 18 more, then 18% would have been gained. Find the cost price?

Chemistry

Non stick cooking utensils are coated with?

Latest Job Notifications

Jobs in West Bengal

इंडियन पोस्ट सर्विस Indian Post Service - 2357 पद - 19/08/2021 अंतिम तिथि - पश्चिम बंगाल पोस्टल सर्कल

Banking Jobs

भारतीय स्टेट बैंक State Bank of India(SBI) - 6100 पद - 26/07/2021 अंतिम तिथि - CRPD/APPR/2021-22/10

SSC Recruitment

कर्मचारी चयन आयोग Staff Selection Commission(SSC) - 25271 पद - 31/08/2021 अंतिम तिथि

Jobs in Madhya Pradesh

राष्ट्रीय स्वास्थ्य मिशन मध्य प्रदेश National Health Mission MP(NRHM) - 5215 पद - 22/06/2021 अंतिम तिथि

Jobs in Punjab

पंजाब स्टेट पावर कॉर्पोरेशन लिमिटेड Punjab State Power Corporation Limited (PSPCL) - 2632 पद - 20/06/2021 अंतिम तिथि

Jobs in Chhattisgarh

स्वास्थ्य सेवा निदेशालय, छत्तीसगढ़ Department of Health & Family Welfare, Chhattisgarh - 267 पद - 26/06/2021 अंतिम तिथि

Government Jobs

दिल्ली सबऑर्डिनेट सर्विस सिलेक्शन बोर्ड Delhi Subordinate Services Selection Board(DSSSB) - 5807 पद - 03/07/2021 अंतिम तिथि

Jobs in Madhya Pradesh

राष्ट्रीय स्वास्थ्य मिशन मध्य प्रदेश National Health Mission MP(NRHM) - 2850 पद - 31/05/2021 अंतिम तिथि

Government Jobs

इंडियन पोस्ट सर्विस Indian Post Service - 4368 पद - 29/05/2021 अंतिम तिथि

दिल्ली सबऑर्डिनेट सर्विस सिलेक्शन बोर्ड Delhi Subordinate Services Selection Board(DSSSB) - 7236 पद - 24/06/2021 अंतिम तिथि