1.下载hibernate-release-4.1.4.Final.zip
2.内置:
文档:hibernate-release-4.1.4.Final/documentation
jar文件:hibernate-release-4.1.4.Final/lib
源代码:hibernate-release-4.1.4.Final/project
其中lib又分为:envers + jpa + optional + required
真正的hibernate是指core文件:
hibernate-release-4.1.4.Final\lib\required\hibernate-core-4.1.4.Final.jar
lib/optional
lib/optional/c3p0 ------>可选连接池
lib/optional/proxool ------>可选连接池
lib/optional/ehcache ------>可选缓存
lib/optional/infinispan------>可选缓存
3.文档又分为:
开发者指南:devguide
API:javadocs
手册:manual
快速入门:quickstart
4.quickstart中例子的源代码在:
hibernate-release-4.1.4.Final\project\documentation\src\main\docbook\quickstart\tutorials\basic
采用的是h2作为内存数据库, 需要下载h2-2012-07-13.zip
如果采用mysql作为数据库,则配置文件hibernate.cfg.xml需要改成:
"-//Hibernate/HibernateConfiguration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
com.mysql.jdbc.Driver
jdbc:mysql://127.0.0.1:3306/mybatis_test
root
admin
1
org.hibernate.dialect.MySQL5InnoDBDialect
org.hibernate.cache.internal.NoCacheProvider
true
create
5.关于hibernate支持的数据库(dialect):
![hibernate4.1.4例子 hibernate4.1.4例子](https://i-blog.csdnimg.cn/blog_migrate/c45415bf18555ecdccc409c6d93f686a.jpeg)
![hibernate4.1.4例子 hibernate4.1.4例子](https://i-blog.csdnimg.cn/blog_migrate/549bf1530007c0007fef98fd28846f9b.jpeg)
Log日志:
Hibernate: drop table if exists EVENTS
Hibernate: create table EVENTS (id bigint not null, EVENT_DATEdatetime, title varchar(255), primary key (id))ENGINE=InnoDB
Hibernate: select max(id) from EVENTS
Hibernate: insert into EVENTS (EVENT_DATE, title, id) values (?, ?,?)
Hibernate: insert into EVENTS (EVENT_DATE, title, id) values (?, ?,?)
Hibernate: select event0_.id as id0_, event0_.EVENT_DATE asEVENT2_0_, event0_.title as title0_ from EVENTSevent0_
在例子:
hibernate-release-4.1.4.Final\project\documentation\src\main\docbook\quickstart\tutorials
basic ------>xml配置测试
annotations ------>annotation配置测试
entitymanager ------>jpa测试
envers------>版本历史测试
其中envers测试在mysql下不稳定(junit显示有时成功,有时失败),原因是两个版本的时间很接近,几乎相等,如:
2012-07-17 21:45:14.0
2012-07-17 21:45:14.0
运行过程中需要暂停几秒,等提交:
// so far the code is the same as we have seen in previoustutorials. Nowlets leverage Envers...
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException e){
e.printStackTrace();
}
try {
System.out.println(firstRevision.getDate());
System.out.println(myEvent.getDate());
assertFalse(firstRevision.getDate().equals( myEvent.getDate() ));
} catch (Throwable e) {
e.printStackTrace();
}
2.内置:
文档:hibernate-release-4.1.4.Final/documentation
jar文件:hibernate-release-4.1.4.Final/lib
源代码:hibernate-release-4.1.4.Final/project
其中lib又分为:envers + jpa + optional + required
真正的hibernate是指core文件:
hibernate-release-4.1.4.Final\lib\required\hibernate-core-4.1.4.Final.jar
lib/optional
lib/optional/c3p0
lib/optional/proxool
lib/optional/ehcache
lib/optional/infinispan------>可选缓存
3.文档又分为:
开发者指南:devguide
API:javadocs
手册:manual
快速入门:quickstart
4.quickstart中例子的源代码在:
hibernate-release-4.1.4.Final\project\documentation\src\main\docbook\quickstart\tutorials\basic
采用的是h2作为内存数据库, 需要下载h2-2012-07-13.zip
如果采用mysql作为数据库,则配置文件hibernate.cfg.xml需要改成:
5.关于hibernate支持的数据库(dialect):
![hibernate4.1.4例子 hibernate4.1.4例子](https://i-blog.csdnimg.cn/blog_migrate/c45415bf18555ecdccc409c6d93f686a.jpeg)
![hibernate4.1.4例子 hibernate4.1.4例子](https://i-blog.csdnimg.cn/blog_migrate/549bf1530007c0007fef98fd28846f9b.jpeg)
Log日志:
Hibernate: drop table if exists EVENTS
Hibernate: create table EVENTS (id bigint not null, EVENT_DATEdatetime, title varchar(255), primary key (id))ENGINE=InnoDB
Hibernate: select max(id) from EVENTS
Hibernate: insert into EVENTS (EVENT_DATE, title, id) values (?, ?,?)
Hibernate: insert into EVENTS (EVENT_DATE, title, id) values (?, ?,?)
Hibernate: select event0_.id as id0_, event0_.EVENT_DATE asEVENT2_0_, event0_.title as title0_ from EVENTSevent0_
在例子:
hibernate-release-4.1.4.Final\project\documentation\src\main\docbook\quickstart\tutorials
basic
annotations
entitymanager
envers------>版本历史测试
其中envers测试在mysql下不稳定(junit显示有时成功,有时失败),原因是两个版本的时间很接近,几乎相等,如:
2012-07-17 21:45:14.0
2012-07-17 21:45:14.0
运行过程中需要暂停几秒,等提交:
// so far the code is the same as we have seen in previoustutorials.
try {
} catch (InterruptedException e){
}
try {
} catch (Throwable e) {
}