hibernate.cfg.xml实例

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

<!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.OracleDriver

</property>

<property name="connection.url">

jdbc:oracle:thin:@localhost:1521:orcl

</property>

<property name="connection.username">scott</property>

<property name="connection.password">tiger</property>

<!-- 辅助参数 -->

<property name="dialect">

org.hibernate.dialect.Oracle10gDialect

</property>

<property name="show_sql">true</property>

<property name="format_sql">true</property>

<property name="current_session_context_class">thread</property>

<!-- 映射信息 ,指明该类的xml文件位置,包名+xml文件名-->

<mapping resource="po/User.hbm.xml"/>

<mapping resource="po/District.hbm.xml"/>

<!-- <mapping resource="po/House.hbm.xml"/> -->

<!-- <mapping resource="po/Street.hbm.xml"/>  -->

</session-factory>

</hibernate-configuration>

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-28 21:35:44

hibernate.cfg.xml实例的相关文章

hibernate hibernate.cfg.xml component 组件

1.为什么使用component组件? 当一个表的列数目比较多时,可以根据属性分类,将一个java对象拆分为几个对象. 数据库还是一张表,不过有多个对象与之对应. 2.实例 2.1 Java 对象: 1 public class Person { 2 3 private int id; 4 private Name name; 5 private Parents parents; 6 7 public Parents getParents() { 8 return parents; 9 } 10

hibernate.cfg.xml配置(Oracle+c3p0)

说明:数据库:Oracle10g:连接池:c3p0 结构: 一.配置hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforg

Hibernate.cfg.xml文件的配置

1.  Hibernate配置 1.1.  可编程的配置方式 一个org.hibernate.cfg.Configuration 实例代表了一个应用程序中Java类型到SQL数据库映射的完整集合.Configuration被用来构建一个 SessionFactory. 映射定义则由不同的XML映射定义文件编译而来. 可以直接实例化Configuration来获取一个实例,并为它指定XML映射定义文件. 如果映射定义文件在类路径(classpath)中,请使用addResource(): Conf

hibernate.cfg.xml配置文件和hbm.xml配置文件 模板

hibernate.cfg.xml配置文件格式 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration

hibernate3配置文件hibernate.cfg.xml的详细解释

<!--标准的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

Hibernate配置文件——hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <

java:Hibernate框架(环境搭建,Hibernate.cfg.xml中属性含义,Hibernate常用API对象,HibernteUitl,对象生命周期图,数据对象的三种状态)

1.环境搭建: 三个准备+7个步骤 准备1:新建项目并添加hibernate依赖的jar文件  准备2:在classpath下(src目录下)新建hibernate的配置文件:hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configurati

spring applicationContext.xml和hibernate.cfg.xml设置

applicationContext.xml配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://ww

Hibernate入门篇&lt;1&gt;hibernate.cfg.xml学习小结

Hibernate配置文件主要用于配置数据库连接和Hibernate运行时所需的各种属性,这个配置文件应该位于应用程序或Web程序的类文件夹 classes中.Hibernate配置文件支持两种形式,一种是xml格式的配置文件,另一种是Java属性文件格式的配置文件,采用"键=值"的形式.建议采用xml格式的配置文件,xml配置文件可以直接对映射文件进行配置,并由Hibernate自动加载,而properties文件则必须在程序中通过编码加载映射文件. 一)hibernate配置文件模