hibernate配置文件详细解释
<!--标准的XML文件的起始行,version='1.0'表明XML的版本,encoding='gb2312'表明XML文件的编码方式-->
<?xml version='1.0' encoding='gb2312'?>
<!--表明解析本XML文件的DTD文档位置,DTD是Document Type Definition 的缩写,即文档类型的定义,XML解析器使用DTD文档来检查XML文件的合法性。hibernate.sourceforge.net/hibernate-configuration-3.0dtd可以在Hibernate3.1.3软件包中的src\org\hibernate目录中找到此文件-->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!--声明Hibernate配置文件的开始-->
<hibernate-configuration>
<!--表明以下的配置是针对session-factory配置的,SessionFactory是Hibernate中的一个类,这个类主要负责保存HIbernate的配置信息,以及对Session的操作-->
<session-factory>
<!--配置数据库的驱动程序,Hibernate在连接数据库时,需要用到数据库的驱动程序-->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver </property>
<!--设置数据库的连接url:jdbc:mysql://localhost/hibernate,其中localhost表示mysql服务器名称,此处为本机, hibernate是数据库名-->
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate </hibernate>
<!--连接数据库是用户名-->
<property name="hibernate.connection.username">root </property>
<!--连接数据库是密码-->
<property name="hibernate.connection.password">123456 </property>
<!--数据库连接池的大小-->
<property name="hibernate.connection.pool.size">20 </property>
<!--是否在后台显示Hibernate用到的SQL语句,开发时设置为true,便于差错,程序运行时可以在Eclipse的控制台显示Hibernate的执行Sql语句。项目部署后可以设置为false,提高运行效率-->
<property name="hibernate.show_sql">true </property>
<!--jdbc.fetch_size是指Hibernate每次从数据库中取出并放到JDBC的Statement中的记录条数。Fetch Size设的越大,读数据库的次数越少,速度越快,Fetch Size越小,读数据库的次数越多,速度越慢-->
<property name="jdbc.fetch_size">50 </property>
<!--jdbc.batch_size是指Hibernate批量插入,删除和更新时每次操作的记录数。Batch Size越大,批量操作的向数据库发送Sql的次数越少,速度就越快,同样耗用内存就越大-->
<property name="jdbc.batch_size">23 </property>
<!--jdbc.use_scrollable_resultset是否允许Hibernate用JDBC的可滚动的结果集。对分页的结果集。对分页时的设置非常有帮助-->
<property name="jdbc.use_scrollable_resultset">false </property>
<!--connection.useUnicode连接数据库时是否使用Unicode编码-->
<property name="Connection.useUnicode">true </property>
<!--connection.characterEncoding连接数据库时数据的传输字符集编码方式,最好设置为gbk,用gb2312有的字符不全-->
<property name="connection.characterEncoding">gbk </property> <!--hibernate.dialect 只是Hibernate使用的数据库方言,就是要用Hibernate连接那种类型的数据库服务器。-->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect </property>
<!--指定映射文件为“hibernate/ch1/UserInfo.hbm.xml”-->
<mapping resource="org/mxg/UserInfo.hbm.xml">
</session-factory>
</hibernate-configuration> <bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
//连接驱动
<property name="driverClassName" value="${jdbc.driverClassName}" />
//连接url,
<property name="url" value="${jdbc.url}" />
//连接用户名
<property name="username" value="${jdbc.username}" />
//连接密码
<property name="password" value="${jdbc.password}" />
</bean> <bean id="hbSessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
//hibernate配置文件位置
<value>WEB-INF/hibernate.cfg.xml </value>
</property>
<property name="configurationClass"
value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="hibernateProperties">
<props>
//针对oracle数据库的方言,特定的关系数据库生成优化的SQL
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
//选择HQL解析器的实现
<prop key="hibernate.query.factory_class">
org.hibernate.hql.ast.ASTQueryTranslatorFactory
</prop>
//是否在控制台打印sql语句
<prop key="hibernate.show_sql">true </prop>
//在Hibernate系统参数中hibernate.use_outer_join被打开的情况下,该参数用来允许使用outer join来载入此集合的数据。
<prop key="hibernate.use_outer_join">true </prop>
//默认打开,启用cglib反射优化。cglib是用来在Hibernate中动态生成PO字节码的,打开优化可以加快字节码构造的速度
<prop key="hibernate.cglib.use_reflection_optimizer">true </prop>
//输出格式化后的sql,更方便查看
<prop key="hibernate.format_sql">true </prop>
//“useUnicode”和“characterEncoding”决定了它是否在客户端和服务器端传输过程中进行Encode,以及如何进行Encode
<prop key="hibernate.connection.useUnicode">true </prop>
//允许查询缓存, 个别查询仍然需要被设置为可缓存的.
<prop key="hibernate.cache.use_query_cache">false </prop>
<prop key="hibernate.default_batch_fetch_size">16 </prop>
//连接池的最大活动个数
<prop key="hibernate.dbcp.maxActive">100 </prop>
//当连接池中的连接已经被耗尽的时候,DBCP将怎样处理(0 = 失败,1 = 等待,2 = 增长)
<prop key="hibernate.dbcp.whenExhaustedAction">1 </prop>
//最大等待时间
<prop key="hibernate.dbcp.maxWait">1200 </prop>
//没有人用连接的时候,最大闲置的连接个数
<prop key="hibernate.dbcp.maxIdle">10 </prop>
##以下是对prepared statement的处理,同上。
<prop key="hibernate.dbcp.ps.maxActive">100 </prop>
<prop key="hibernate.dbcp.ps.whenExhaustedAction">1 </prop>
<prop key="hibernate.dbcp.ps.maxWait">1200 </prop>
<prop key="hibernate.dbcp.ps.maxIdle">10 </prop>
</props>
</property>
</bean>
hibernate配置文件详细解释的更多相关文章
- hibernate配置文件详细解析
在javaweb开发中,hibernate框架的是常用的,能帮我们节省大量的时间,以下是hibernate的配置文件解析. hibernate配置文件的默认名为:hibernate.cfg.xml 默 ...
- Hibernate配置详细解释
hibernate.cfg.xml <!--标准的XML文件的起始行,version='1.0'表明XML的版本,encoding='gb2312'表明XML文件的编码方式--> < ...
- Hibernate配置详细解释(转 )
hibernate.cfg.xml <!--标准的XML文件的起始行,version='1.0'表明XML的版本,encoding='gb2312'表明XML文件的编码方式--> < ...
- log4j配置文件详细解释
web.xml中配置启动log4j的配置 <!-- webAppRootKey进行配置,这里主要是让log能将日志写到对应项目根目录下 --> <!-- 定义以后,在Web Cont ...
- Nginx配置文件详细解释
转自:https://www.cnblogs.com/knowledgesea/p/5175711.html 序言 Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开 ...
- hibernate配置文件hibernate.cfg.xml和.hbm.xml的详细解释
原文地址:http://blog.csdn.net/qiaqia609/article/details/9456489 hibernate.cfg.xml -标准的XML文件的起始行,version= ...
- hibernate配置文件hibernate.cfg.xml的详细解释
<!--标准的XML文件的起始行,version='1.0'表明XML的版本,encoding='gb2312'表明XML文件的编码方式--> <?x ...
- hibernate篇章三-- hibernate配置文件hibernate.cfg.xml的详细解释
<!--标准的XML文件的起始行,version='1.0'表明XML的版本,encoding='gb2312'表明XML文件的编码方式--> <?xml version='1.0' ...
- 转: hibernate配置文件hibernate.cfg.xml和.hbm.xml的详细解释
http://blog.csdn.net/yuhui123999/article/details/51886531 hibernate.cfg.xml -标准的XML文件的起始行,version='1 ...
随机推荐
- JavaScript【5】高级特性(作用域、闭包、对象)
笔记来自<Node.js开发指南>BYVoid编著 1.作用域 if (true) { var somevar = 'value'; } console.log(somevar); Jav ...
- centos 5.4 安装nodejs + npm(转)
而在安装nodejs的时候,需要用到,所以需要手动安装bz2库. sudo yum install -y bzip2* cd Python-/Modules/zlib ./configure make ...
- shell 两个rpm包做差分
当前目录下两个rpm包做差分. *.rpm 两个目录,解压rpm包. export LANG=c 差分判断是脚本还是Binary Files 脚本添加命令行提示符,awk. [root@sj_x8 ...
- 【转】Win7环境下VS2010配置Cocos2d-x-2.1.4最新版本的开发环境(亲测)
http://blog.csdn.net/ccf19881030/article/details/9204801 很久以前使用博客园博主子龙山人的一篇博文<Cocos2d-x win7+vs20 ...
- iOS中的imageIO与image解码
ImageIO对外开放的对象有CGImageSourceRef.CGImageDestinationRef,不对外开放的对象有CGImageMetadataRef.CoreGraphics中经常与im ...
- (原创)speex与wav格式音频文件的互相转换
我们的司信项目又有了新的需求,就是要做会议室.然而需求却很纠结,要继续按照原来发语音消息那样的形式来实现这个会议的功能,还要实现语音播放的计时,暂停,语音的拼接,还要绘制频谱图等等. 如果是wav,m ...
- Spring MVC 3.0.5+Spring 3.0.5+MyBatis3.0.4全注解实例详解(二)
在上一篇文章中我详细的介绍了如何搭建maven环境以及生成一个maven骨架的web项目,那么这章中我将讲述Spring MVC的流程结构,Spring MVC与Struts2的区别,以及例子中的一些 ...
- 1066. Root of AVL Tree
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child su ...
- Failed to create a 'System.Type' from the text ' ' in wpf(无法从文本创建类型)
问题描述:WPF is unable to create a type for data templateWPF使用mvvm模式无法加载DataTemplate模板定义的资源,提示无法从文本创建类型错 ...
- 关于cnpm的一点小bug
在实际工作中,一个项目完成后,在上线前,常常需要把代码进行压缩,一般是用gulp或者 webpack 进行压缩.(小妹是用gulp) gulp是运行在node 环境下的. 所以首先,下载并安装了nod ...