hibernate配置文件详细解析

在javaweb开发中,hibernate框架的是常用的,能帮我们节省大量的时间,以下是hibernate的配置文件解析。

hibernate配置文件的默认名为:hibernate.cfg.xml 默认在WEB-INF/class下 。

 <?xml version="1.0" encoding="utf-8"?>

  配置文件dto信息(DTO解释百度百科

<!DOCTYPE hibernate-configuration PUBLIC

          "-//Hibernate/Hibeinate Configurantion dtd 3.0 // EM"

           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

配置文件的根元素

<hibernate-configuration>

<session-factory>

配置jdbc驱动(以mysql为例)

 <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

配置数据库连接URL

<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/aisky</property>

配置数据库用户

<property name="hibernate.connection.username">root</property>

配置数据库密码

<property name="hibernate.connection.password">root</property>

配置数据方言

<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

配置内置jdbc连接数

<property name="hibernate.connection.pool.size">1</property>

配置数据库方言

<peoperty name="dialect">org.hibernate.dialect.MySQLDialect</peoperty>

列出所有的映射文件信息

<mappiong resource>org/hibernate.entity/user.hbm.xml</mappiong resource>

</session-factory>

</hibernate-configuration>

                                                                 jdbc连接属性表

属性名
作用
hibernate.connection.driver_class
                  加载jdbc驱动
hibernate.connection.url
                  jdbc url连接串
hibernate.connection.name
                 数据库用户名
hibernate.connection.password
                   数据库密码
hibernate.connection.pool_size
                  最大的池连接数


posted @ 2016-03-30 13:34  西海_westsea  阅读(288)  评论(0)    收藏  举报