Tuesday, March 31, 2009

Hibenate Coding Steps

Steps to Code Hibenate :
1.Edit hibernate.cfg.xml :
Hibernate uses the hibernate.cfg.xml to create the connection pool and setup required environment. Add an Entry for ???.hbm.xml

2.Create Table in databse

3.Create POJO Class which contains getter and setter method

4.Map Table Column vs POJO Class in .hbm.xml

5.Write Client Program

SessionFactory factory=null;
Session ses=null;
Transaction tx=null;
try
{ factory=new Configuration().configure().buildSessionFactory();
ses=factory.openSession();
tx = ses.beginTransaction();
ses.save(emp);
tx.commit();
}
catch (Exception e)
{
}

No comments: