Posted by: jigsaw
Posted on: 2005-06-03 14:31
我什么都不懂。。。不过这段抄自refrence里面的话对你可能有点用。。
10.7. Automatic state detection
The usage and semantics of saveOrUpdate() seems to be confusing for new users. Firstly, so long as you are not trying to use instances from one session in another new session, you should not need to use update(), saveOrUpdate(), or merge(). Some whole applications will never use either of these methods.
Usually update() or saveOrUpdate() are used in the following scenario:
the application loads an object in the first session
the object is passed up to the UI tier
some modifications are made to the object
the object is passed back down to the business logic tier
the application persists these modifications by calling update() in a second session
saveOrUpdate() does the following:
if the object is already persistent in this session, do nothing
if another object associated with the session has the same identifier, throw an exception
if the object has no identifier property, save() it
if the object's identifier has the value assigned to a newly instantiated object, save() it
if the object is versioned (by a <version></version>or <timestamp></timestamp>), and the version property value is the same value assigned to a newly instantiated object, save() it
otherwise update() the object
and merge() is very different:
if there is a persistent instance with the same identifier currently associated with the session, copy the state of the given object onto the persistent instance
if there is no persistent instance currently associated with the session, try to load it from the database, or create a new persistent instance
the persistent instance is returned
the given instance does not become associated with the session, it remains detached |
相关推荐
Spring提供了很多IoC特性的支持,方便处理大部分典型的Hibernate整合问题。 如:SessionFactory的注入、HibernateTemplate的简化操作、DAO的支持等。 为了更好地与持久层框架整合,Spring还提供了统一的异常处理体系...
Struts+Hibernate+Spring面试题合集及答案 Struts+Hibernate+Spring面试题合集 1 1. Hibernate部分 2 1.1. Hibernate工作原理 2 1.2. 什么是Hibernate的并发机制?怎么处理并发问题? 2 1.3. Hibernate自带的分页...
HibernateTemplate对Hibernate Session操作进行了封装,而 HibernateTemplate.execute方法则是一封装机制的核心 *在spring的配置文件里,移植了整个hibernate.cfg.xml的内容。
(Struts 2+Spring 2+Hibernate 3).pdf(完整版) 网上有高清版350M的。可以去下 http://115.com/file/be5gwid8 请于下载后 24H 内及时删除!请抱着学习的态度下载此资料。 总共900多页!!!!!!! 第1篇 ...
9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 11、iBatis与Hibernate有什么不同? 12、写...
9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、iBatis与Hibernate有什么不同? 122 12、...
9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、iBatis与Hibernate有什么不同? 122 12、...
9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、iBatis与Hibernate有什么不同? 122 12、...
9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、iBatis与Hibernate有什么不同? 122 12、...
9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、iBatis与Hibernate有什么不同? 122 12、...
9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、iBatis与Hibernate有什么不同? 122 ...
9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 133 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 133 11、iBatis与Hibernate有什么不同? 133 12、...
9、hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。 122 10、简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件. 122 11、iBatis与Hibernate有什么不同? 122 12、...
事实上针对单个对象的get/load/persist/save/update/merge/saveOrUpdate API和Criteria API本来就为一体,只不过是历史的原因被人为割裂成为两套数据库操作API罢了。 因此,对于关系型数据库而言——Entity和...
一. Java 基础部分..................................................................................................................... 7 1、一个".java"源文件中是否可以包括多个类(不是内部类)?...