/UserApp---Hibernate-Project

The Hibernate Project is a powerful and widely-used object-relational mapping (ORM) framework for Java applications. It simplifies the development process by providing a seamless bridge between object-oriented programming and relational databases.

Primary LanguageJava

UserApp---Hibernate-Project

A CRUD project using hibernate ORM tool

  1. Create from scratch , hibernate n maven based Java SE application.

Steps to create Hibernate projct.

  1. Change perspective to Java

  2. Create Maven Project ---skip archetype selection -- grp id,artifact id , packaging option : jar --finish

  3. Creates default pom.xml . Add n tags from text file - pom file.

  4. Update the project . R click on the project --> Maven --> Update Project -->select Force update checkbox -->Finish

  5. Edit hibernate.cfg.xml , as per your DB settings.

  6. Take help of hib-fgg-xml text file

  7. Create HibernateUtils class to create singleton , immutable , inherently thrd safe SessionFactory instance.

  8. Create a class TestHibernate under package. Add following code.

import static utils.HibernateUtils.; import org.hibernate.;

public class TestHibernate {

public static void main(String[] args) {
	try(SessionFactory sf=getSf())
	{
		System.out.println("Hibernate booted.....");
	}catch (Exception e) {
		e.printStackTrace();
	}

}

}

  1. Run this as "java application" , check console to see , sf created & hib booted .

Above confirms bootstrapping of hibernate framework.

  1. Create a POJO n test auto table creation 9.1 Create a User POJO Add these Data members userId (PK) ,name,email,password,confirmPassword,role(enum), regAmount; LocalDate/Date regDate; byte[] image; Add JPA annotations (javax.persistence) Confirm auto table creation.

9.2 Add entry per POJO in hibernate.cfg.xml Run TestHibernate to confirm auto table creation.

  1. Create Hibernate based DAO layer , to insert a record. 10.1 DAO layer i/f String registerUser(User user); 10.2 Hibenrate based DAO implementation class no data mebers, no constr,no clean up CRUD method

  2. Create a main(...) based tester to test entire application , for user registration.