我自己的hibernate的配置

来源:互联网 发布:联通大数据精准营销 编辑:程序博客网 时间:2024/04/28 20:37

<?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>
  <!--c3p0数据库连接池配置 -->
  <propertyname="hibernate.c3p0.min_size">5</property>
  <propertyname="hibernate.c3p0.max_size">30</property>
  <!--获取连接的超时时间,单位毫秒 -->
  <propertyname="hibernate.c3p0.time_out">1800</property>
  <!--最大的preparedStatement数量 -->
  <propertyname="hibernate.c3p0.max_statements">50</property>
  <!--每隔多少秒检查连接池里的空闲连接 -->
  <propertyname="hibernate.c3p0.idle_test_period">120</property>
  <!--当池中的连接耗尽的时候,一次性增加的连接数量,默认为3 -->
  <propertyname="hibernate.c3p0.acquire_increment">3</property>
  <!-- 每次都验证连接是否可用-->
  <propertyname="hiberate.c3p0.validate">true</property>
  <!--最大空闲时间多少秒内未使用则连接被丢弃,若为0则永不丢弃 -->
  <propertyname="hibernate.c3p0.maxIdleTime">25000</property>

  <!--程序执行的时候是否显示真正的sql语句 -->
  <propertyname="show_sql">true</property>
  <!-- ANSI SQL-99标准定义了下列隔离级别:
   Hibernate在配置文件中声明事务的隔离级别,Hibenate 获取数据库连接后,将根据隔离级别自动设置数据库连接为指定的事务隔离级别。
   <propertyname="connection.isolation">8</property>
   ● 未提交读(ReadUncommitted):隔离事务的最低级别,只能保证不会读取到物理上损坏的数据。Hibernate配置:1;允许产生:1,2,3
   ● 已提交读(ReadCommitted):常见数据库引擎的默认级别,保证一个事务不会读取到另一个事务已修改但未提交的数据。Hibernate配置:2;允许产生:1,2
   ●可重复读(RepeatableRead):保证一个事务不能更新已经由另一个事务读取但是未提交的数据。相当于应用中的已提交读和乐观并发控制。Hibernate配置:4;允许产生:1
   ●可串行化(Serializable):隔离事务的最高级别,事务之间完全隔离。系统开销最大。Hibernate配置:8;这种情况很容易造成死锁的问题,hibernate表现为:
   Deadlockfound when trying to get lock; try restartingtransaction  -->
  <propertyname="connection.isolation">2</property>
  <!--数据库连接url
   <propertyname="connection url">
   jdbc:mysql://125.216.247.15:3306/test
   </property>-->
  <!--使用的SQL对应的“方言”,此处是MySQL的方言 -->
  <propertyname="dialect">util.MyMySQLDialect</property>
  <!-- 用户名-->
  <propertyname="connection.username">root</property>
  <!-- 密码-->
  <propertyname="connection.password">******</property>
  <!--连接数据库的Driver -->
  <propertyname="connection.driver_class">
   com.mysql.jdbc.Driver
  </property>

  <!--指定了根据实体配置文件来自动生成表
   create:表示启动的时候先drop,再create
   create-drop:也表示创建,只不过再系统关闭前执行一下drop
   update:这个操作启动的时候会去检查schema是否一致,如果不一致会做scheme更新
   validate:启动时验证现有schema与你配置的hibernate是否一致,如果不一致就抛出异常,并不做更新-->

  <!--指定了关联的所有实体配置文件,其中包括:create/create-drop/update/validate四种可选方式-->
  <propertyname="myeclipse.connection.profile">
   mysqlConnector
  </property>
  <propertyname="connection.url">
   jdbc:mysql://localhost:3306/wlw?characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;transformedBitIsBoolean=true
  </property>
  <mappingresource="beans/Order.hbm.xml" />
  <mappingresource="beans/Storageout.hbm.xml" />
  <mappingresource="beans/Storagein.hbm.xml" />
  <mappingresource="beans/Checkstorageout.hbm.xml" />
  <mappingresource="beans/Admin.hbm.xml" />
  <mappingresource="beans/Productin.hbm.xml" />
  <mappingresource="beans/Judger.hbm.xml" />
  <mappingresource="beans/Gps.hbm.xml" />
  <mappingresource="beans/Buy0.hbm.xml" />
  <mappingresource="beans/Tutor.hbm.xml" />
  <mappingresource="beans/Storageproduct.hbm.xml" />
  <mappingresource="beans/Family.hbm.xml" />
  <mappingresource="beans/Gameinfor.hbm.xml" />
  <mappingresource="beans/Producttype.hbm.xml" />
  <mappingresource="beans/Department.hbm.xml" />
  <mappingresource="beans/Driver.hbm.xml" />
  <mappingresource="beans/Product.hbm.xml" />
  <mappingresource="beans/Productout.hbm.xml" />
  <mappingresource="beans/Checkstoragein.hbm.xml" />
  <mappingresource="beans/Charger.hbm.xml" />
  <mappingresource="beans/Sport.hbm.xml" />
  <mappingresource="beans/Supply.hbm.xml" />
  <mappingresource="beans/Gym.hbm.xml" />
  <mappingresource="beans/Media.hbm.xml" />
  <mappingresource="beans/Player.hbm.xml" />
  <mappingresource="beans/Car.hbm.xml" />
  <mappingresource="beans/Storage.hbm.xml" />
  <mappingresource="beans/Entrust.hbm.xml" />
  <mappingresource="beans/Departmentman.hbm.xml" />
  <mappingresource="beans/Buy.hbm.xml" />
  <mappingresource="beans/Waybill.hbm.xml" />
  <mappingresource="beans/Entrustproduct.hbm.xml" />
  <mappingresource="beans/Logistic.hbm.xml" />

 </session-factory>
</hibernate-configuration>

0 0
原创粉丝点击