hibernate3 学习笔记(二) hibernate 的配置文件 hibernate.cfg.xml
来源:互联网 发布:湖畔大学网络课程视频 编辑:程序博客网 时间:2024/06/06 03:59
对于hibernate 来说, hibernate.cfg.xml 是一个非常重要的文件,它采用 XML 的格式,保存一些非常重要的参数,如数据库连接信息,连接池等:
下面是一个项目中的 hibernate.cfg.xml 实例:
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE hibernate-configuration
- PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
- <hibernate-configuration>
- <session-factory name="cdma">
- <!-- local connection properties -->
- <property name="hibernate.connection.url">
- jdbc:oracle:thin:@10.52.16.138:1521:oragxlu
- </property>
- <property name="hibernate.connection.driver_class">
- oracle.jdbc.driver.OracleDriver
- </property>
- <property name="hibernate.connection.username">cdmagis</property>
- <property name="hibernate.connection.password">cdmagis</property>
- <!-- property name="hibernate.connection.pool_size"></property -->
- <!-- dialect for Oracle (any version) -->
- <property name="dialect">
- org.hibernate.dialect.OracleDialect
- </property>
- <property name="hibernate.show_sql">true</property>
- <property name="hibernate.transaction.factory_class">
- org.hibernate.transaction.JDBCTransactionFactory
- </property>
- <mapping resource="CdmaBts.hbm.xml" />
- </session-factory>
- </hibernate-configuration>
刚开始部分,就是XML文件的标准头信息,只需要注意一下版本情况。
- <property name="hibernate.connection.url">
- jdbc:oracle:thin:@10.52.16.138:1521:oragxlu
- </property>
属性 hibernate.connection.url 用来记录数据库连接信息,连接方式等信息,如上面显示采用 jdbc 的连接方式,目的数据库是
Oracle, 采用 thin 的连接,紧接着,是 DB 的 IP 信息,最后是 DB 的 SID。
- <property name="hibernate.connection.driver_class">
- oracle.jdbc.driver.OracleDriver
- </property>
这部分用于描述连接 DB 采用的驱动方式。
- <property name="hibernate.connection.username">cdmagis</property>
- <property name="hibernate.connection.password">cdmagis</property>
这两部分,就是 DB 的用户名和密码。
<!-- property name="hibernate.connection.pool_size"></property -->
这部分是连接池是的配置记录,本例中没有使用连接池,所以就注释掉了,如果要使用连接池,只需要在属性中说明连接池的大小,就可以了。
- <property name="dialect">
- org.hibernate.dialect.OracleDialect
- </property>
SQL方言,具体的用法还不太明白。
<property name="hibernate.show_sql">true</property>
指明日志输出时,是否输出SQL。如果要研究一下 hibernate 的内部实现,这个功能是很有用的,因为所有的数据库操作,实际就是SQL的执行过程。
- <property name="hibernate.transaction.factory_class">
- org.hibernate.transaction.JDBCTransactionFactory
- </property>
事务管理配置。
<mapping resource="CdmaBts.hbm.xml" />
这个配置是重要的,如果我们要生成某个表的持久层,必须要在这儿进行 mapping 的配置。
- hibernate3 学习笔记(二) hibernate 的配置文件 hibernate.cfg.xml
- Hibernate学习--配置文件hibernate.cfg.xml详解
- Hibernate学习之配置文件hibernate.cfg.xml
- Hibernate的学习(创建配置文件hibernate.cfg.xml)
- hibernate的hibernate.cfg.xml配置文件
- 深入Hibernate 的配置文件hibernate.cfg.xml
- Hibernate的配置文件hibernate.cfg.xml
- Hibernate的主配置文件hibernate.cfg.xml
- Hibernate的主配置文件hibernate.cfg.xml
- Hibernate的主配置文件hibernate.cfg.xml
- Hibernate的主配置文件hibernate.cfg.xml
- Hibernate的主配置文件hibernate.cfg.xml
- Hibernate的主配置文件hibernate.cfg.xml
- Hibernate配置文件hibernate.cfg.xml的详解
- hibernate.cfg.xml 配置文件
- hibernate.cfg.xml配置文件
- hibernate.cfg.xml配置文件
- hibernate.cfg.xml配置文件
- 删除空格自定义函数
- 建立自己的.net类库
- 关于SOA几个问题的理解
- 关于Div CSS布局:文本输入框与文本或按钮垂直不对齐
- prototype.js开发笔记
- hibernate3 学习笔记(二) hibernate 的配置文件 hibernate.cfg.xml
- How to set background image of a component in GWTEXT
- .NET类库
- .net类库-续(MSDN)
- 新家
- .net类库-再续(MSDN)
- CSS常用技巧
- WinForm文件目录结构
- CBitmap::LoadBitmap问题