0% found this document useful (0 votes)
237 views2 pages

Steps To Set Up A Hibernate Project

This document outlines the steps to set up a Hibernate project which includes: 1. Adding necessary jar files 2. Configuring the hibernate.cfg.xml file to define database connection details and mapping files 3. Creating a HibernateUtil class to get the SessionFactory instance

Uploaded by

f2003027
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
237 views2 pages

Steps To Set Up A Hibernate Project

This document outlines the steps to set up a Hibernate project which includes: 1. Adding necessary jar files 2. Configuring the hibernate.cfg.xml file to define database connection details and mapping files 3. Creating a HibernateUtil class to get the SessionFactory instance

Uploaded by

f2003027
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Steps to set up a Hibernate Project.

1. jar files

2. hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>


<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property
name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDri
ver</property>
<property
name="hibernate.connection.url">jdbc:oracle:thin:@172.19.13.107:1521:
TEST
</property>
<property
name="hibernate.connection.username">hib_test</property>
<property
name="hibernate.connection.password">hib_test</property>
<property name="hibernate.connection.pool_size">2</property>
<property name="show_sql">true</property>
<property
name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping
resource="com/java/hibernate/pojo/UserDetail.hbm.xml"/>
</session-factory>
</hibernate-configuration>
3. HibernateUtil

package com.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil


{
private static SessionFactory sessionFactory;

private HibernateUtil()
{
super();
}

private static void init()


{
sessionFactory = new
Configuration().configure().buildSessionFactory();
}

public static SessionFactory getSessionFactory()


{
if(sessionFactory == null)
{
init();
}
return sessionFactory;
}
}

You might also like