hibernate.cfm.xml的配置详解

  1.    
  2.                 xml version='1.0' encoding='gb2312'?>   
  3.    
  4.           "-//Hibernate/Hibernate Configuration DTD 3.0//EN"   
  5.           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">   
  6.             
  7.     <hibernate-configuration>   
  8.        
  9.       <session-factory>      
  10.          
  11.           <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver property>   
  12.           
  13.             <property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate hibernate>   
  14.        
  15.           <property name="hibernate.connection.username">root property>   
  16.              
  17.           <property name="hibernate.connection.password">123456 property>          
  18.              
  19.           <property name="hibernate.connection.pool.size">20 property>          
  20.            
  21.         <property name="hibernate.show_sql">true property>   
  22.            
  23.         <property name="jdbc.fetch_size">50 property>   
  24.            
  25.         <property name="jdbc.batch_size">23 property>   
  26.            
  27.         <property name="jdbc.use_scrollable_resultset">false property>   
  28.            
  29.         <property name="Connection.useUnicode">true property>   
  30.            
  31.     <property name="connection.characterEncoding">gbk property>        
  32.           
  33.            
  34.           <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect property>   
  35.                   
  36.           <mapping resource="org/mxg/UserInfo.hbm.xml">   
  37.   session-factory>   
  38.   hibernate-configuration>      
  39.     
  40.     
  41.     
  42.   <bean id="dataSource"    
  43.   class="org.apache.commons.dbcp.BasicDataSource"    
  44.   destroy-method="close">    
  45. //连接驱动      
  46.   <property name="driverClassName" value="${jdbc.driverClassName}" />    
  47. //连接url,      
  48. <property name="url" value="${jdbc.url}" />    
  49. //连接用户名      
  50.   <property name="username" value="${jdbc.username}" />    
  51. //连接密码      
  52.   <property name="password" value="${jdbc.password}" />    
  53. bean>    
  54.     
  55. <bean id="hbSessionFactory"    
  56.   class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">    
  57.   <property name="dataSource" ref="dataSource" />    
  58.   <property name="configLocation">    
  59. //hibernate配置文件位置      
  60.   <value>WEB-INF/hibernate.cfg.xml value>    
  61.   property>    
  62.   <property name="configurationClass"    
  63.   value="org.hibernate.cfg.AnnotationConfiguration" />    
  64.   <property name="hibernateProperties">    
  65.   <props>    
  66.   //针对oracle数据库的方言,特定的关系数据库生成优化的SQL      
  67.     <prop key="hibernate.dialect">    
  68.     org.hibernate.dialect.OracleDialect      
  69.     prop>    
  70.   //选择HQL解析器的实现      
  71.     <prop key="hibernate.query.factory_class">    
  72.     org.hibernate.hql.ast.ASTQueryTranslatorFactory      
  73.     prop>    
  74.     //是否在控制台打印sql语句      
  75.     <prop key="hibernate.show_sql">true prop>    
  76.     //在Hibernate系统参数中hibernate.use_outer_join被打开的情况下,该参数用来允许使用outer join来载入此集合的数据。      
  77.     <prop key="hibernate.use_outer_join">true prop>    
  78.   //默认打开,启用cglib反射优化。cglib是用来在Hibernate中动态生成PO字节码的,打开优化可以加快字节码构造的速度      
  79.   <prop key="hibernate.cglib.use_reflection_optimizer">true prop>    
  80.   //输出格式化后的sql,更方便查看      
  81.   <prop key="hibernate.format_sql">true prop>    
  82.   //“useUnicode”和“characterEncoding”决定了它是否在客户端和服务器端传输过程中进行Encode,以及如何进行Encode      
  83.   <prop key="hibernate.connection.useUnicode">true prop>    
  84.   //允许查询缓存, 个别查询仍然需要被设置为可缓存的.      
  85.   <prop key="hibernate.cache.use_query_cache">false prop>    
  86.   <prop key="hibernate.default_batch_fetch_size">16 prop>    
  87.     //连接池的最大活动个数      
  88.     <prop key="hibernate.dbcp.maxActive">100 prop>    
  89.   //当连接池中的连接已经被耗尽的时候,DBCP将怎样处理(0 = 失败,1 = 等待,2  =  增长)      
  90.     <prop key="hibernate.dbcp.whenExhaustedAction">prop>    
  91.     //最大等待时间      
  92.     <prop key="hibernate.dbcp.maxWait">1200 prop>    
  93.     //没有人用连接的时候,最大闲置的连接个数      
  94.     <prop key="hibernate.dbcp.maxIdle">10 prop>    
  95.     ##以下是对prepared statement的处理,同上。      
  96.     <prop key="hibernate.dbcp.ps.maxActive">100 prop>    
  97.     <prop key="hibernate.dbcp.ps.whenExhaustedAction">prop>    
  98.     <prop key="hibernate.dbcp.ps.maxWait">1200 prop>    
  99.     <prop key="hibernate.dbcp.ps.maxIdle">10 prop>    
  100.   props>    
  101.   property>    
  102. bean>    

你可能感兴趣的:(hibernate.cfm.xml的配置详解)