公共领域如何“打破延迟加载”在教义2? [英] How can public fields "break lazy loading" in Doctrine 2?

查看:117
本文介绍了公共领域如何“打破延迟加载”在教义2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 doctrine orm:validate-schema 时,会弹出一堆关于我的映射列为public的警告,而不是使用getter / setter方法来包装它们。它说他们懒惰装载。我可以理解如何使关联的集合 public可能是有问题的(我做这些私有并包装它们),但是对于对象的字段来说这是一个问题?据我所知,字段已经被充满了。

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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