First Hibernate Application

First let us know, what are the important interfaces ans classes. The following are the most important interfaces and classes. 
Important interfaces and classes in Hibernate
Fig: Important interfaces and classes in Hibernate


The following are the steps which will be used to develop Hibernate Application:
  • Create Configuration object by using configuration class.
  • Call the configure() method using the above configuration object.
  • Get SessionFactory object by using configuration object by using "buildSessionFactory()" method.
  • Get Session object using SessionFactory object, by calling openSession() method. 
  • Get Transaction object by calling the method beginTransaction().
  • Create the POJO class object corresponding to the table.
  • Store the data in the form of object.
  • Ask Hibernate to perform CURD operations.The following are the curd operations. The following are the operations.

      1. save()        // create  
      2. update()   //  update
      3. load()       //  select /Retrieve
      4. delete()   //  delete

  • End the Transaction by calling commit() and rollback().
  • Close the session object.
  • Close the SessionFactory object.
Now let us develop the first Hibernate application, let us insert a record into the emp table. The following program inserts the record into emp table.
Hibernate application to Insert Record into Employee table
Fig: Hibernate application to Insert Record into Employee table

                                                               

No comments:

Post a Comment