Tuesday, March 17, 2009

Hibernate Important Interview Question

1.What is O-R Mapping?
2.What is the difference between createCriteria and createQuery in Hibernate?
3.How would you implement on deletecasecade in Hiberante?
4.How Inheritance Implemented in Hiberante?
5.Is one Bean class can be involved with more than one relationship?
For example 1 class may have 1 to 1 and 1 to many
6.How do define compound primary key?
7.How to implement Oncasecasde deletion?
8.What is cascade="all"

Code Examples :

What are the steps to be followed to implement 1 to 1 database insert/update/delete?

Pre - Request :
Check we able to connect databse through Sample JSP program.

Step 1:

Table and Bean :

Create master table and Child table
Create bean for Master and Child table. Here Both Bean should contain gettter and setter value of other bean.


XML Entry :

In Master

Apart from XML Entry, There should be map to child table

<one-to-one name="<<Childtablename>>" class="<<ChildtableClass>>" cascade="all" />

<one-to-one name="employeeSalary" class="EmployeeSalary" cascade="all" />

Note : it refers only the class

In Child table

refer the master table's as below

In reference key column,

a)metioned generator class =foreign then mention property name
b)define one to one with property name and Class

No comments: