Without Book Interview Questions and Answers | Online Test | Moct Test
Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Institute Training Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Hibernate Interview Questions and Answers

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

Ans. 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)?
Ans. 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?
Ans. * 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?
Ans. 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()?
Ans. 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:

©2016 WithoutBook