How can public fields quot;break lazy loadingquot; in Doctrine 2?(公共字段如何“打破延迟加载?在教义 2 中?)
问题描述
当我运行 doctrine orm:validate-schema
时,它会弹出一堆关于我的映射列是公开的并且没有使用 getter/setter 方法来包装它们的警告.它说他们打破延迟加载".我可以理解如何将 关联集合 设为公开可能会出现问题(我确实将这些设为私有并包装了它们),但是对于对象上的字段来说,这如何成为问题?据我所知,字段已全部加载.
When I run doctrine orm:validate-schema
, it pops up a bunch of warnings about my mapped columns being public and not using getter/setter methods to wrap them. It says that they "break lazy loading". I can understand how making associated collections public could be problematic (I do make these private and wrap them), but how is this an issue for fields on the object? Fields are loaded in full, to my knowledge.
推荐答案
尽管我肯定不是 Doctrine2 专家,但我会尝试一下.
从我的(有限的)使用和测试来看,Doctrine 可能会为您提供一个相关的对象而无需加载该对象的数据.那时公共属性将破坏延迟加载.
From my (limited) usage and testing it seems Doctrine may give you a related object without loading the data for that object. At that point public properties will break lazy loading.
Doctrine 是在请求持久化数据时延迟加载,而不是在请求包含持久化数据的对象时.
Doctrine is lazy loading at the point where the persisted data is requested, not when the object that contains persisted data is requested.
更新:我查看了 实际代理代码 看来我原来的理解大多是正确的.在调用对象的方法之前,代理对象不会加载自身.因此,对公共属性的任何请求都不会加载数据.
Update: I took a look at the actual proxy code and it seems my original understanding was mostly correct. The proxy object doesn't load itself until a method of the object is called. So any request to a public property would not load the data.
这篇关于公共字段如何“打破延迟加载"?在教义 2 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:公共字段如何“打破延迟加载"?在教义 2 中?


基础教程推荐
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01