merge只是简单的把对像关联到session中事务提交后更改数据库,update会直接更改数据库吧
解决方案 »
- 请教高手!jmx在tomcat中的作用??
- 关于struts1的一个问题,求解惑!
- 获得后台返回数组的元素个数?
- ServletActionContext.getRequest()的问题
- 遇到一个Tomcat乱码的问题,觉的很奇怪,网上的方法都试了,还是没有解决,请高手近来看看
- 程序问题!为何做成package会出现错误!!!!
- 当使用struts 连接数据库时,想向各位咨询getDataSource这个函数以及参数细节。谢谢。
- 急!急!急!有关<<Thinking in JAVA>>的问题
- webstart下运行显示空界面
- SpringBoot+FreeMark静态资源无法访问
- 想将自己的技术能力很快的提高吗?想和天下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判断,如果是没有保存状态,就做新增;否则,就从数据库装载该对象。