“这些实体是私有的"是什么意思?是指(如 Doctrine 官方文档中所见)? [英] what does "the entities are privately owned" means (as seen in Doctrine official documentation)?

查看:19
本文介绍了“这些实体是私有的"是什么意思?是指(如 Doctrine 官方文档中所见)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在教义文档中阅读了以下对我来说意义不大的内容:

I have read the following in doctrine documentation that does not mean much to me:

当使用 orphanRemoval=true 选项时,Doctrine 使假设实体是私有的并且不会被其他实体重用.

When using the orphanRemoval=true option Doctrine makes the assumption that the entities are privately owned and will NOT be reused by other entities.

在这里您可以在其上下文中找到该句子的链接.学说官方文档

here the link where you can find the sentence in its context. doctrine official documentation

谁能给我一个私有实体在实体之间的 ManyToMany 关系中的示例?

Can someone could give me an example of privately own entities in a ManyToMany relationship between entities?

推荐答案

假设您将一些用户设置存储在 Settings 实体中,该实体附加到 User 实体通过一对多或一对一关系,Settings 实体不会在多个用户之间共享,也不会在引用的用户被删除时被重用,你可以说SettingsUser 私有所有,如果 User 被删除将成为孤儿,orphanRemoval=true 会阻止它当其母亲"User 实体被删除时,通过删除 Settings 来发生.

Imagine you're storing some user settings in a Settings entity which is attached to a User entity via a One-To-Many or One-To-One relation, the Settings entity won't be shared amongst several users, nor will it be reused if it's referenced user gets removed, you could say that Settings is privately owned by User and would become an orphan if User gets deleted, orphanRemoval=true prevents that from happening by deleting Settings when its "mother" User entity gets removed.

关于 SO 的其他一些您可能会感兴趣的问题:

Some other questions on SO that you might find interesting :

关于多对多关系,您可以在此类关系上使用 orphanRemoval 并且 Doctrine 将简单地删除附加的实体,即使它们仍然附加到其他实体.请注意,尽管此选项适用于多对多关系,但并未正式记录此类关系:

Concerning Many-To-Many relations, you can use orphanRemoval on such relations and Doctrine will simply remove attached entities, even if they are still attached to other entities. Note that even though this option will work on Many-To-Many relations, it is not officially documented for such relations :

我认为在多对多关系上没有私有实体的任何示例,或者它不会是多对多,但 Doctrine 只是做了 假设它是,并且无论如何都会继续删除附加的实体.

I don't think there's any example of a privately owned entity on a Many-To-Many relation, or it wouldn't be Many-To-Many, but Doctrine just makes the assumption it is, and will proceed to remove attached entities anyway.

这篇关于“这些实体是私有的"是什么意思?是指(如 Doctrine 官方文档中所见)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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