下载地址:
- hibernate.cfg.xml(hibernate配置文件,现在一般都是采用xml文件来进行配置的,但是当hibernate与spring整合时,我们通常是不需要hibernate的配置文件了,因为我们会在spring的配置文件ApplicationContext.xml中直接将hibernate的相关配置配置成Spring容器所管理的bean)
- hibernate.properties(不会采用该文件来配置,当时其中提供了相应的hibernate的属性,在我们配置hibernate.cfg.xml或ApplicationContext.xml时时会用到的)
- domain.hbm.xml(domain对象映射到数据中表的映射文件)
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="foo">
<property name="show_sql">true</property>
<mapping resource="org/hibernate/test/legacy/Simple.hbm.xml"/>
<class-cache
class="org.hibernate.test.legacy.Simple"
region="Simple"
usage="read-write"/>
</session-factory>
</hibernate-configuration>
一个dtd文件:hibernate-configuration-3.0.dtd(作用:是hibernate.cfg.xml的语法约束文件。可以将hibernate3.jar文件解压后到org\hibernate文件夹下找)
- <hibernate-configuration>(只有一个)
- <session-factory>(只有一个,用于配置SessionFactory对象)
- <property>(多个,用于配置SessionFactory对象的属性)
- <mapping>(多个,用于映射:domain.hbm.xml文件)
- 等等
## MySQL (MySQL的相关映射)
#hibernate.dialect org.hibernate.dialect.MySQLDialect (设置方言)
#hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect
#hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect
#hibernate.connection.driver_class com.mysql.jdbc.Driver
#hibernate.connection.url jdbc:mysql:///test
#hibernate.connection.username gavin
#hibernate.connection.password
#hibernate.dialect org.hibernate.dialect.Oracle9iDialect
#hibernate.dialect org.hibernate.dialect.Oracle10gDialect
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
#hibernate.connection.username ora
#hibernate.connection.password ora
#hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl
#hibernate.connection.url jdbc:oracle:thin:@localhost:1522:XE
hibernate.show_sql true
hibernate.format_sql true
#hibernate.hbm2ddl.auto create-drop
#hibernate.hbm2ddl.auto create
#hibernate.hbm2ddl.auto update
#hibernate.hbm2ddl.auto validate
### C3P0 Connection Pool###
###########################
#hibernate.c3p0.max_size 2
#hibernate.c3p0.min_size 2
#hibernate.c3p0.timeout 5000
#hibernate.c3p0.max_statements 100
#hibernate.c3p0.idle_test_period 3000
#hibernate.c3p0.acquire_increment 2
#hibernate.c3p0.validate false
- hibernate.show_sql
- hibernate.format_sql
- hibernate.hbm2ddl.auto
- hibernate.dialect(设置方言)
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.jast.blog.domain">
<class name="Article">
<id name="id" column="article_id" type="integer">
<generator class="identity"></generator>
</id>
<property name="title" type="string" />
<property name="content" type="string"/>
</class>
</hibernate-mapping>
说明:hibernate-mapping-3.0.dtd文件(作用:domain.hbm.xml是的语法约束文件。可以将hibernate3.jar文件解压后到org\hibernate文件夹下找)
646



被折叠的 条评论
为什么被折叠?



