merge只是简单的把对像关联到session中事务提交后更改数据库,update会直接更改数据库吧
解决方案 »
- 三大框架整合后一些配置文件不懂
- hibernate中如何执行show tables
- 求助servlet怎么使用apache的xmlrpc
- 最近研究Tomcat源码.可以看到tomcat用了一种"钩子"机制(hook),谁能讲讲什么是钩子机制,一般用在什么场合
- 如何改变tomcat访问地址??在线=
- hibernate问题
- 用jbuilder 7开发CMP 的问题?
- 请帮忙看看 代码为什么不循环!!!
- 问j2sdk1.4的XML解析API与JAXP关系
- J2EE构建企业系统--清华大学出版社--.....
- 想将自己的技术能力很快的提高吗?想和天下J2EE高手会合吗?
- 高手帮帮忙,很急,我是新手郁闷的找不出来,谢谢大家帮忙,struts(MVC)
merge:根据所给对象的id值来判断是更新还新增。
看看doc得api,
Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy of and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped with cascade="merge".
,根据对象得id判断,如果是没有保存状态,就做新增;否则,就从数据库装载该对象。