Steps to use hibernate into an application

May 1st, 2011No Comments

1. Load the Hibernate Into Configuration File: -

Configuration conf = new Configuration ();
Conf. Configure (“anyname.cfg.xml”);

2. Parse The Loaded Xml And Generate SessionFactory: -

SessionFactory factory = conf. buildSessionFactory ();

3. Open a Session from SessionFactory: -

It internally opens a connection
Session ses = factory. openSession ()

4. Start a Transaction: -

Transaction tx= ses. beginTransaction ();

5. Do the persistency operations required

6. Commit or Rollback the Transaction: -

tx. Commit () / tx. Rollback ();
7. Close the Session: -

ses.close ()

VN:F [1.9.10_1130]
Rating: 9.3/10 (3 votes cast)
VN:F [1.9.10_1130]
Rating: +3 (from 3 votes)

Steps to use hibernate into an application, 9.3 out of 10 based on 3 ratings

About author:

All entries by

Leave a Reply