Hibernate笔记_object state
2016-06-16 17:31
429 查看
作为一款功能强大的ORM工具,Hibernate应该具有哪些功能?
1)对象在Hibernate中的状态:transient and persistent。
transient: never persistent, not associated with any Session
persistent: associated with a unique Session
detached: previously persistent, not associated with any Session
Transient instances may be made persistent by calling save(), persist() or saveOrUpdate(). Persistent instances may be made transient by calling delete(). Any instance returned by a get() or load() method is persistent. Detached instances may be made persistent
by calling update(), saveOrUpdate(), lock() or replicate(). The state of a transient or detached instance may also be made persistent as a new persistent instance by calling merge().
save() and persist() result in an SQL INSERT, delete() in an SQL DELETE and update() or merge() in an SQL UPDATE. Changes to persistent instances are detected at flush time and also result in an SQL UPDATE. saveOrUpdate() and replicate() result in either an
INSERT or an UPDATE.
It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.
2)从对象关联(association)的角度来设计映射
2.1)Album->Track (Fowler:Dependent Mapping)得到的映射就是OneToMany;
2.2)Album->Artist (Fowler:Foreign Key Mapping)得到的映射就是ManyToOne;
2.3)Employee->Skill(Fowler:Association Table Mapping)得到的映射就是ManyToMany;
1)对象在Hibernate中的状态:transient and persistent。
transient: never persistent, not associated with any Session
persistent: associated with a unique Session
detached: previously persistent, not associated with any Session
Transient instances may be made persistent by calling save(), persist() or saveOrUpdate(). Persistent instances may be made transient by calling delete(). Any instance returned by a get() or load() method is persistent. Detached instances may be made persistent
by calling update(), saveOrUpdate(), lock() or replicate(). The state of a transient or detached instance may also be made persistent as a new persistent instance by calling merge().
save() and persist() result in an SQL INSERT, delete() in an SQL DELETE and update() or merge() in an SQL UPDATE. Changes to persistent instances are detected at flush time and also result in an SQL UPDATE. saveOrUpdate() and replicate() result in either an
INSERT or an UPDATE.
It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.
2)从对象关联(association)的角度来设计映射
2.1)Album->Track (Fowler:Dependent Mapping)得到的映射就是OneToMany;
2.2)Album->Artist (Fowler:Foreign Key Mapping)得到的映射就是ManyToOne;
2.3)Employee->Skill(Fowler:Association Table Mapping)得到的映射就是ManyToMany;
相关文章推荐
- iOS Objective-C Associated Objects 的实现原理
- [Nutch]编译hadoop出现object[]无法转换为K[]问题解决
- The kernel object namespace and Win32, part 3
- The kernel object namespace and Win32, part 2
- The kernel object namespace and Win32, part 1
- Objective-C 运行时编程
- SQL系统表sysobjects和syscolumns字段属性介绍
- ios学习路线—Objective-C(Runtime类与对对象)
- 解压jdk1.8安装包(exe)后,java.version -version报错 Error occurred during initialization of VM,java/lang/NoClassDefFoundError: java/lang/Object
- ios学习路线—Objective-C(Runtime消息机制)
- JsonObject Integer 0
- ios学习路线—Objective-C(新特性)
- YYModel 源码解读(二)之NSObject+YYModel.h (3)
- Objective-C语法之KVC使用
- ios学习路线—Objective-C(NSObject)
- 自定义控件三部曲之动画篇(七)——ObjectAnimator基本使用
- JSONObject的遍历
- #106 – Set Property Value to Point to Another Object(设置属性值指向另一个object)
- [Training Video - 3] [Java Introduction] [Object Oriented Programming]
- 【OBJC类扩展之属性字典】NSObject+Property