Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Hibernate Interview Questions and Answers

Test your skills through the online practice test: Hibernate Quiz Online Practice Test

Related differences

Ques 21. What is the general flow of Hibernate communication with RDBMS?

The general flow of Hibernate communication with RDBMS is :
* Load the Hibernate configuration file and create configuration object. It will automatically load all hbm mapping files
* Create session factory from configuration object
* Get one session from this session factory
* Create HQL Query
* Execute query to get list containing Java objects

Is it helpful? Add Comment View Comments
 

Ques 22. What is Hibernate Query Language (HQL)?

Hibernate offers a query language that embodies a very powerful and flexible mechanism to query, store, update, and retrieve objects from a database. This language, the Hibernate query Language (HQL), is an object-oriented extension to SQL.

Is it helpful? Add Comment View Comments
 

Ques 23. How do you map Java Objects with Database tables?

* First we need to write Java domain objects (beans with setter and getter). The variables should be same as database columns.

* Write hbm.xml, where we map java class to table and database columns to Java class variables.



Example :

<hibernate-mapping>

<class name="com.test.User" table="user">

<property column="USER_NAME" length="255″
name="userName"; not-null="true" type="java.lang.String"/>

<property column="USER_PASSWORD" length="255″
name="userPassword" not-null="true" type="java.lang.String"/>

</class>

</hibernate-mapping>

Is it helpful? Add Comment View Comments
 

Ques 24. What Does Hibernate Simplify?

Hibernate simplifies:

* Saving and retrieving your domain objects
* Making database column and table name changes
* Centralizing pre save and post retrieve logic
* Complex joins for retrieving related items
* Schema creation from object model

Is it helpful? Add Comment View Comments
 

Ques 25. What is the difference between load() and get()?

load() vs. get()

load() :-
Only use the load() method if you are sure that the object exists.
load() method will throw an exception if the unique id is not found in the database. load() just returns a proxy by default and database won't be hit until the proxy is first invoked.

get():- If you are not sure that the object exists, then use one of the get() methods.
get() method will return null if the unique id is not found in the database.
get() will hit the database immediately.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook
Hibernate 3 vs Hibernate 4JDBC vs HibernateJPA vs Hibernate