HibernateInAction

对象关系映射:静态结构
1. property: name column not-null;同名 column可省
2. 双向关联,两个对象互相add后,hibernate发现内存中两个持久化对象改变了,
数据库角度来看,只需要子表改变:需要用inverse告诉hibernate是many-to-one的mirror;
在one一边设置cascade=save-update
 
对象存取:动态
1. Object LifeCircle persistent manager:Session
2. 隐式持久化:class不需知道其持久化能力、
    应用逻辑不需要知道其操作对象是持久的还是只存在于内存中
3. persistent lifecircle:transient/persistent/detached
4. persistent instances are always associated with a Session and are transactional.
5. automatic dirty checking : ORM software must have a strategy for detecting 
   which persistent objects have been modified by the application in the transaction
6. dynamic-update="true":Hibernate can detect exactly which attributes have been modified, 
so it’s possible to include only the columns that need updating in the SQL UPDATE statement. 
This might bring performance gains, particularly with certain databases. However, 
it isn’t usually a significant difference, and, in theory, it could harm performance 
in some environments. So, by default, Hibernate includes all columns in the SQL 
UPDATE statement (hence, Hibernate can generate this basic SQL at startup, not at 
runtime). If you only want to update modified columns, you can enable dynamic 
SQL generation   
7. Session.close():所有对象状态改为Detached
8. The scope of object identity: 不同事物域允许的persistent object的个数,事物不限制/事物内只一个/jvm只一个
   Session实现事务内:session查数据库两次,返回jvm内同一个对象的两个引用
   
Persistent Manager   
1. Persistence by reachability:向下的对象图被持久化,但是数据库不支持
2. cascade:默认不会实现Persistence by reachability; none/save-update/delete/all/all-delete-orphan/delete-orphan
3. 区别transient/detached:identifier version unsaveForClass unsavedForVersion 
4. four fetching strategies for any association:
Immediate fetching:The associated object is fetched immediately, using a sequential database read
Lazy fetching:
Eager fetching:使用join
Batch fetching: