日期:2014-05-16  浏览次数:20545 次

hibernate的配置和初始化数据库
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>

<!-- MSSQL 版-->
<property name="connection.driver_class">
net.sourceforge.jtds.jdbc.Driver
</property>
<property name="connection.url">jdbc:jtds:sqlserver://localhost:1433;DatabaseName=数据库名称</property>
<property name="connection.username"></property>
<property name="connection.password"></property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

<!-- ORACLE 版 
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:ORCL</property>
<property name="connection.username"></property>
<property name="connection.password"></property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
-->
<!--初始化系统库  -->
<property name="sqlServer.initDB">
/resources/standard/initDB/step_1_create_table.sql,
/resources/standard/initDB/step_2_init_data_cfg.sql,
/resources/standard/initDB/step_3_init_data_dm.sql,
/resources/standard/initDB/step_4_add_pk.sql,
/resources/standard/initDB/step_5_add_fk.sql,
/resources/standard/initDB/step_6_create_view.sql,
/resources/standard/initDB/step_7_init_text_data.sql,
<!--
<property name="oracle.initDB">
/resources/standard/initDB_ORACLE/step_1_create_table.sql,
/resources/standard/initDB_ORACLE/step_2_init_data_cfg.sql,
/resources/standard/initDB_ORACLE/step_3_init_data_dm.sql,
/resources/standard/initDB_ORACLE/step_4_add_pk.sql,
/resources/standard/initDB_ORACLE/step_5_add_fk.sql,
/resources/standard/initDB_ORACLE/step_6_create_view.sql,
/resources/standard/initDB_ORACLE/step_7_init_text_data.sql,
</property>
-->
<!-- 以下为JNDI的配制方法  start -->
<!-- Tomcat 需要加前缀java:comp/env/ Weblogic 不需要  -->
<!--
<property name="connection.datasource">java:comp/env/jdbc/TestDB</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
-->
<!-- 以上为JNDI的配制方法  end -->

<!-- 性能测试
<property name="hibernate.c3p0.max_size">30</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.timeout">20000</property>
<property name="hibernate.c3p0.max_statements">50</property>
         <property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.jdbc.batch_size">20</property>
<property name="hibernate.jdbc.fetch_size">50</property>
-->

<property name="myeclipse.connection.profile">standard</property>
<mapping resource="com/eplugger/business/schema/paper.hbm.xml" />
<!--审计监听 -->
  <listener type="post-insert" class="com.eplugger.maintain.history.controller.HistoryListener"/>
    <listener type="pre-delete" class="com.eplugger.maintain.history.controller.HistoryListener"/> 
    <listener type="pre-update" class="com.eplugger.maintain.history.controller.HistoryListener"/>
</session-factory>
</hibernate-configuration>