Doctrine2 one-to-one relation auto loads on query

前端 未结 6 1705
借酒劲吻你
借酒劲吻你 2020-12-23 12:53

I have a query that looks like this:

My user entity has a one-to-one relation that looks like this:

/**
 * @var UserProfile
 *
 * @ORM\\OneToOne(targ         


        
6条回答
  •  太阳男子
    2020-12-23 13:50

    It seems that this is a open issue in Doctrine, see also

    4.7.1. Why is an extra SQL query executed every time I fetch an entity with a one-to-one relation?

    If Doctrine detects that you are fetching an inverse side one-to-one association it has to execute an additional query to load this object, because it cannot know if there is no such object (setting null) or if it should set a proxy and which id this proxy has. To solve this problem currently a query has to be executed to find out this information.

    Source

提交回复
热议问题