Hbernate的主配置文件hibernate.cfg.xml
2014-04-29 02:55
375 查看
hibernate.cfg.xml存放在src目录下,在添加Myeclipse对Hibernate的支持时可选择是否自动生成,也可手动添加。
<?xmlversion='1.0'encoding='UTF-8'?>
<!DOCTYPEhibernate-configuration(根元素)PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<propertyname="connection.url">jdbc:mysql://localhost:3306/hibernate(操纵的是hibernate数据库)</property>
<propertyname="connection.username">root</property>
<propertyname="connection.password">qiang</property>
<propertyname="connection.driver_class">com.mysql.jdbc.Driver</property>
<propertyname="dialect">org.hibernate.dialect.MySQL5Dialect</property>(方言)
<propertyname="show_sql">true</property>(是否显示SQL语句,因为我们会通过hibernate操纵SQL语句)
<mappingresource="Person.hbm.xml"/>(指定对象关系映射文件)
</session-factory>
</hibernate-configuration>
说明:
hibernate.dialect:指定数据库使用的SQL方言;(可以到hibernate API中查询)
hibernate.connection.url:指定连接的url
hibernate.connection.username:指定连接数据库的用户名
hibernate.connection.password:指定连接数据库的口令
hibernate.connection.driver_class:指定数据库的驱动程序
hibernate.show_sql:指定是否在控制台输出SQL语句,默认为false,在开发阶段最好设置为true以便跟踪Hibernate的运行状态和调试应用程序;在应用发布阶段应将其设
为 false以减少语句输出,提高运行时的性能。
(上述name="show_sql"可省略hibernate,也可name="hibernate.show_sql")
<mappingresource="Person.hbm.xml"/>指定了针对于Person类的映射文件,若有多个映射文件,可用多个<mapping>指定。所有的对象关系映射文件都要在hibernate.cfg.xml文件中用<mapping>指定,也正是这样,Hibernate才会知道类和表的映射关系。
<?xmlversion='1.0'encoding='UTF-8'?>
<!DOCTYPEhibernate-configuration(根元素)PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<propertyname="connection.url">jdbc:mysql://localhost:3306/hibernate(操纵的是hibernate数据库)</property>
<propertyname="connection.username">root</property>
<propertyname="connection.password">qiang</property>
<propertyname="connection.driver_class">com.mysql.jdbc.Driver</property>
<propertyname="dialect">org.hibernate.dialect.MySQL5Dialect</property>(方言)
<propertyname="show_sql">true</property>(是否显示SQL语句,因为我们会通过hibernate操纵SQL语句)
<mappingresource="Person.hbm.xml"/>(指定对象关系映射文件)
</session-factory>
</hibernate-configuration>
说明:
hibernate.dialect:指定数据库使用的SQL方言;(可以到hibernate API中查询)
hibernate.connection.url:指定连接的url
hibernate.connection.username:指定连接数据库的用户名
hibernate.connection.password:指定连接数据库的口令
hibernate.connection.driver_class:指定数据库的驱动程序
hibernate.show_sql:指定是否在控制台输出SQL语句,默认为false,在开发阶段最好设置为true以便跟踪Hibernate的运行状态和调试应用程序;在应用发布阶段应将其设
为 false以减少语句输出,提高运行时的性能。
(上述name="show_sql"可省略hibernate,也可name="hibernate.show_sql")
<mappingresource="Person.hbm.xml"/>指定了针对于Person类的映射文件,若有多个映射文件,可用多个<mapping>指定。所有的对象关系映射文件都要在hibernate.cfg.xml文件中用<mapping>指定,也正是这样,Hibernate才会知道类和表的映射关系。
相关文章推荐
- Hibernate的学习(创建配置文件hibernate.cfg.xml)
- hibernate.cfg.xml---hibernate配置文件,基本版
- hibernate.cfg.xml配置文件对关联关系的书写技巧!
- Hibernate连接MySql数据库时 Hibernate.cfg.xml配置文件
- hibernate中的配置文件hibernate.cfg.xml的详解总结
- 关于SSH框架配置文件 Hibernate.cfg.xml 、struts.xml、spring.xml
- Hibernate配置文件(Hibernate.cfg.xml)
- hibernate.cfg.xml配置文件,连接oracle数据库和mysql 数据库
- hibernate.cfg.xml注解和*.hbm.xml配置文件详解
- hibernate配置文件hibernate.cfg.xml的详细解释
- Hibernate.cfg.xml配置文件
- 使用Hibernate时,hibernate.cfg.xml的配置文件内容
- hibernate.cfg.xml配置文件
- Hibernate.cfg.xml配置文件结构详解
- 为什么hibernate在不联网的时候解析不了配置文件?(hibernate.cfg.xml)
- hibernate.cfg.xml文件的配置
- hibernate.cfg.xml配置文件
- hibernate3 学习笔记(二) hibernate 的配置文件 hibernate.cfg.xml
- 8. Hibernate_配置文件详解hibernate.cfg.xml
- hibernate.cfg.xml配置文件