REFRESH和MERGE在数据库方面意味着什么? [英] What do REFRESH and MERGE mean in terms of databases?

查看:308
本文介绍了REFRESH和MERGE在数据库方面意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,需要快速找到这个答案。谷歌将无济于事。



Java Persistence API具有这些属性,告诉框架在关联实体上级联操作:

  CascadeType.PERSIST 
CascadeType.DELETE
CascadeType.MERGE
CascadeType.REFRESH

我知道前两个是什么意思:当我持有有B的对象A时,也坚持B,当我删除A时,也删除B.



但我无法理解其他两个人所取得的成就。帮助?

解决方案

REFRESH表示将任何状态更改从数据库拉到我的表示中。层叠这很简单;这意味着所有关联的实体都会被刷新。



MERGE意味着复杂的东西近似保存但更像是将这个分离的实体推回到托管状态并保存其状态变化;级联意味着所有关联的实体以相同的方式被推回,并且您从 .merge()返回的托管实体句柄具有与之关联的所有管理实体。 / p>

链接到相关的一个实例docs


I'm curious and need to find this answer quick. Google won't help much.

The Java Persistence API has these properties that tell the framework to cascade operations on associated entities:

CascadeType.PERSIST
CascadeType.DELETE
CascadeType.MERGE
CascadeType.REFRESH

I know what the first two mean: when I persist object A which has B, persist B as well, and when I delete A, delete B as well.

But I can't make any sense of what the other two accomplish. Help?

解决方案

REFRESH means "pull any state changes from the database into my representation". Cascading this is simple; it means that all associated entities are refreshed.

MERGE means something complex that approximates "save" but is more like "push this detached entity back into managed status and save its state changes"; the cascading means that all associated entities get pushed back the same way, and the managed-entity handle you get back from .merge() has all managed entities associated with it.

Link to one instance of the relevant docs

这篇关于REFRESH和MERGE在数据库方面意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆