Article Directory
Writing rules Hibernate persistent classes
无参数构造
属性私有
属性尽量使用包装类
提供一个唯一OID与主键对应
不要使用final修饰
Hibernate primary key generation strategy
Hibernate的主键生成策略
主键分类
自然主键
代理主键
主键生成策略
increment
identity
sequence
uuid
native
assigned
foreign
Hibernate three states of persistent classes
瞬时态:没有唯一标识OID,没有被session管理
持久态:有唯一标识OID,已经被session管理
脱管态:有唯一标识OID,没有被session管理
Hibernate's cache
一级缓存:Hibernate优化手段,称为是session级别缓存。
一级缓存:快照区
Hibernate transaction management
事务的回顾
事务的概念
事务的特性
引发安全性问题
安全性问题解决
Hibernate解决读问题
配置设置隔离级别
Hibernate解决Service事务
采用的是线程绑定的方式:
``
<!-- 设置事务隔离级别 -->
<property name="hibernate.connection.isolation">4</property>
Configuration thread-bound Session
A configuration tools
public static Session getCurrentSession(){
return sf.getCurrentSession();
}
Two modify the core profile
<!-- 配置当前线程绑定的Session -->
<property name="hibernate.current_session_context_class">thread</property>
Other API Hibernate's
Query :HQL 面向对象方式的查询。
Criteria :QBC 完成面向对象化。
SQLQuery :SQL查询