hibernate.cfg.xml详解

hibernate.cfg.xml主要设置数据库产生连接的一些参数,生成session。
下面主要对里面的一些配置做一些说明:	
数据库连接设置:
	数据库驱动
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
	数据库url地址
        <property name="connection.url">jdbc:mysql://localhost/hibernate</property>
	用户名
        <property name="connection.username">root</property>
	密码
        <property name="connection.password">123</property>
 
数据库链接池的大小的设置:
	<property name="connection.pool_size">1</property>
 
数据库方言设置:
	<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
   
   
DB2org.hibernate.dialect.DB2Dialect
DB2 AS/400org.hibernate.dialect.DB2400Dialect
DB2 OS390org.hibernate.dialect.DB2390Dialect
PostgreSQLorg.hibernate.dialect.PostgreSQLDialect
MySQLorg.hibernate.dialect.MySQLDialect
MySQL with InnoDBorg.hibernate.dialect.MySQLInnoDBDialect
MySQL with MyISAMorg.hibernate.dialect.MySQLMyISAMDialect
Oracle (any version)org.hibernate.dialect.OracleDialect
Oracle 9i/10gorg.hibernate.dialect.Oracle9Dialect
Sybaseorg.hibernate.dialect.SybaseDialect
Sybase Anywhereorg.hibernate.dialect.SybaseAnywhereDialect
Microsoft SQL Serverorg.hibernate.dialect.SQLServerDialect
SAP DBorg.hibernate.dialect.SAPDBDialect
Informixorg.hibernate.dialect.InformixDialect
HypersonicSQLorg.hibernate.dialect.HSQLDialect
Ingresorg.hibernate.dialect.IngresDialect
Progressorg.hibernate.dialect.ProgressDialect
Mckoi SQLorg.hibernate.dialect.MckoiDialect
Interbaseorg.hibernate.dialect.InterbaseDialect
Pointbaseorg.hibernate.dialect.PointbaseDialect
FrontBaseorg.hibernate.dialect.FrontbaseDialect
Firebirdorg.hibernate.dialect.FirebirdDialect
AccessAccess数据库的方言包:http://www.hxtt.com/test/hibernate.zip 路径:com.hxtt.support.hibernate.HxttAccessDialect

如果是在web容器中运行hibernate,则在hibernate.cfg.xml中加入这句话:

<property name="hibernate.current_session_context_class">jta</property>

如果是在一个单独的需要进行JDBC连接的java application中运行hibernate,则这样设置:

<property name="hibernate.current_session_context_class">thread</property>

二级缓存的配置:

不使用二级缓存

<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

使用二级缓存

<property name="hibernate.cache.use_query_cache">true</property>

<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值