Download Saving Objects with Hibernate Example Project


Version
Download14
Stock
File Size8.00 KB
Create DateSeptember 6, 2016
Download

Saving Objects with Hibernate Example Project Description

In this Saving Objects with Hibernate example project, we wrote hibernate.cfg.xml and we did following things in this file

  1. Configured our database related information in it
  2. Entered the dialect
  3. Added the mapping class (fully qualified name of the model class)
  4. We also wrote UserDetails.java Class which is our Model class in this class we have done following things
    1. Used annotations like
      @Entity (to tell hibernate that this class should he handled as entity)
      @Id with one of the attribute to make it a primary key.
    2. Created a private field in this class, fields are
      userId
      userName
      Generated getters and setters for these fields
  5. We wrote HibernateMain.java Class which is our Main class in this class we have done following things
    1. Created an object of UserDetails class
    2. Set the field values in it by using setters
    3. With the help of SessionFactory and Session objects, we have saved the object of UserDetails.

Click here to Learn Saving Objects with Hibernate

Inserted values of Object
Inserted values of Object