Hibernate Config

A basic Hibernate configuration file

dmcnelis
February 16, 2012







<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>

        <!-- Database connection settings -->
        <property name="connection.driver_class">%{driver_class_name_with_pkg}%</property>
        <property name="connection.url">%{db_url_with_port}%</property>
        <property name="connection.username">%{db_username}%</property>
        <property name="connection.password">%{db_password}%</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">%{db_pool_size}%</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.%{db_dialect}%</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        
		<property name="hibernate.c3p0.acquire_increment">2</property>
		<property name="hibernate.c3p0.idle_test_period">300</property>
		<property name="hibernate.c3p0.timeout">1800</property>
		<property name="hibernate.c3p0.max_size">25</property>
		<property name="hibernate.c3p0.min_size" >3</property>
		<property name="hibernate.c3p0.max_statement">0</property>
		<property name="hibernate.c3p0.preferredTestQuery">select 1;</property>
		<property name="hibernate.c3p0.validate">true</property>
		<property name="c3p0.testConnectionOnCheckout">true</property>
		
        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">%{show_sql}%</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>

       
        

    </session-factory>

</hibernate-configuration>