在Doctrine/PHP的ManyToOne注解中,属性fetch的默认值是什么?

huangapple go评论53阅读模式
英文:

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

https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/tutorials/extra-lazy-associations.html#extra-lazy-associations

huangapple
  • 本文由 发表于 2023年4月13日 16:02:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76003038.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定