0% found this document useful (0 votes)
7 views

Lab Sequence

The document provides steps to create a Java SE application using Hibernate and Maven. It describes creating a Maven project, configuring dependencies and Hibernate, bootstrapping Hibernate, creating POJOs and testing auto table creation, implementing a DAO layer to insert records, and testing the full application.

Uploaded by

Anushka Pawar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lab Sequence

The document provides steps to create a Java SE application using Hibernate and Maven. It describes creating a Maven project, configuring dependencies and Hibernate, bootstrapping Hibernate, creating POJOs and testing auto table creation, implementing a DAO layer to insert records, and testing the full application.

Uploaded by

Anushka Pawar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

Test the
same.

Steps for Hibernate + Java SE


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 <build> n <dependencies> tags from day7_help\


hibernate-help\config-files\pom.xml

4. Update the project .


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

4. Copy from the day7_help\hibernate-help\config-files\hibernate.cfg.xml under :


src/main/resources .
Edit hibernate.cfg.xml , as per your DB settings.

OR
Simpler alternative :
Simply import test_hibernate_basic , as existing Maven project

6. Create HibernateUtils class to create singleton , immutable , inherently thrd


safe SessionFactory instance.

7. Create a class TestHibernate under <tester> 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();
}

8. Run this as "java application" , check console to see ,


sf created & hib booted .

Above confirms bootstrapping of hibernate framework.

9. Create a POJO n test auto table creation

9.2 Add <mapping> entry per POJO in hibernate.cfg.xml


Run TestHibernate to confirm auto table creation.
10. 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

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

You might also like