英文:
What is the default for the attribute fetch in a ManyToOne annotation in Doctrine/PHP?
问题
如果我不在@ManyToOne
注释中指定fetch
属性,它默认是什么?在这篇文章中提到,JPA和Hibernate在Java中已经以不同的方式处理它,所以我想确切知道默认是什么,而不是猜测。在doctrine文档中,我找到了哪些属性是必需的,哪些是可选的。但我没有找到有关如果省略可选属性时默认值是什么的信息。
英文:
I have this class, using Doctrine/PHP:
class Client {
/** @ORM\ManyToOne(targetEntity="Fee", fetch="EAGER") @ORM\JoinColumn() */
private ?Fee $defaultFee;
// [...]
}
If I don't specify the fetch
-Attribute in the @ManyToOne
-annotation, what does it default to?
In this article, it says that JPA and Hibernate handle it differently already in Java, so I would like to know for sure what the default is, instead of guessing.
In the doctrine documentation I found which attributes are required and which ones are optional. But I didn't find any information about what is the default, if the optional attributes are left out.
答案1
得分: 1
默认为懒加载。
> 关联默认标记为懒加载,这意味着首次访问关联的整个集合对象会被填充。如果您将关联标记为“extra lazy”,则可以调用集合上的以下方法,而不触发集合的完全加载。
链接:https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/tutorials/extra-lazy-associations.html#extra-lazy-associations
英文:
The default is lazy
> Associations are marked as Lazy by default, which means the whole collection object for an association is populated the first time its accessed. If you mark an association as extra lazy the following methods on collections can be called without triggering a full load of the collection
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论