admin管理员组

文章数量:1317898

I have the following table definition for Doctrine ORM:

 <entity name="My\Namespace\User" table="users" >

    //some fields here, not important

    <many-to-one field="duplicateOf" target-entity="My\Namespace\User" fetch="EXTRA_LAZY">
        <join-column name="duplicate_of" referenced-column-name="id" />
    </many-to-one>
</entity>

with it's corresponding entity:

class User
{
    private int $id;
    private ?User $duplicateOf = null;
}

As you can see, there is a duplicate_of column, because there can be duplicate accounts in my case. And the entity can have objects of the same type as itself inside it.

Here's my question: If I do this:

$qb = $this->entityManager->getRepository(User::class)->createQueryBuilder('u');

$qb->where('u.duplicateOf IS NULL')
   ->orderBy('...');

//other logic, execute query etc.

In this case, will $duplicateOf be populated by a User object, even though I explicitly marked it as extra-lazy ? Can Doctrine perform the ...IS NULL check without hydrating?

本文标签: phpWill Doctrine ORM load the entity in WHERE clause even though it39s marked as Extra LazyStack Overflow