Hibernate 配置文件解析

来源:互联网 发布:java jelly 编辑:程序博客网 时间:2024/06/11 09:22

hibernate-release-4.3.11.Final下载百度云链接密码: bqix

Hibernate主配置文件hibernate.cfg.xml解析

<?xml version='1.0' encoding='utf-8'?><!--  ~ Hibernate, Relational Persistence for Idiomatic Java  ~  ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.  ~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.  --><!DOCTYPE hibernate-configuration PUBLIC        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"><hibernate-configuration> <session-factory>     <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>     <!--配置数据库的驱动程序,Hibernate在连接数据库时,需要用到数据库的驱动程序-->      <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>     <!--设置数据库的连接url:jdbc:oracle:thin:@localhost:1521:orcl-->     <property name="connection.username">muzi</property>     <!--连接数据库时用户名-->        <property name="connection.password">123456</property>     <!--连接数据库时密码-->        <property name="connection.pool_size">1</property>     <!--数据库连接池的大小-->        <property name="dialect">org.hibernate.dialect.OracleDialect</property>      <!--hibernate.dialect 指定Hibernate使用的数据库方言,即指定Hibernate连接那种类型的数据库服务器。-->        <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>     <property name="show_sql">true</property>     <!--是否在后台显示Hibernate用到的SQL语句-->        <property name="hbm2ddl.auto">update</property>     <mapping resource="hibernate2/student.hbm.xml"/>       <!--映射文件位置-->   </session-factory></hibernate-configuration>

映射配置文件解析

<?xml version="1.0"?><!DOCTYPE hibernate-mapping PUBLIC        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><hibernate-mapping package="hibernate1"> <!-- 指定Java对象和数据库表之间映射 -->    <class name="Student" table="t_student">         <!-- 对象属性和数据库表字段进行映射 -->           <!--对象中的主键属性 id hibernate中必须配置 -->        <id name="id" column="id">            <generator class="sequence" >                  <!-- hibernate_sequence -->                <param name="sequence">seq_student</param>              </generator>        </id>        <property name="name" column="name"/>        <property name="age" column="age"/>         <!-- 可选属性                  type:指定java类型                 not-null:属性不能为空                 unique:记录必须唯一                 length:对属性的长度进行检查           -->    </class></hibernate-mapping>