Вы находитесь на странице: 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;
}
}

Вам также может понравиться