I am having a hard time finding the correct result for this.
I have one to one mapping. There are two tables:
/**
* @ORM\\Table(name=\"users\")
* @ORM\\E
Use hint HINT_FORCE_PARTIAL_LOAD to avoid lazy-loading.
...
$qb->getQuery()->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
You can enable extra lazy loading of associations using fetch="EXTRA_LAZY"
in your annotations.
* @ORM\OneToOne(targetEntity="Users", inversedBy="userSetting", fetch="EXTRA_LAZY")
Inverse sides of one-to-one associations can not be lazy.
Explanation:
This is expected behavior. There is no foreign key on the inverse side, hence it is impossible to decide whether to proxy it or not. We must query for the associated object or join it. Note that this only affects inverse sides of single-valued associations, that is, really only the inverse side of bidirectional one-to-one associations.
Why we cannot create proxy without FK?
It is pretty simple, in a one-to-many association where the one-side is the inverse side, it holds a collection. The collection may be empty or not but there can always be a collection so it easy and correct to always put a proxy collection there.
If you have a single-valued side that is the inverse side, how can you decide whether to put a proxy object there or not? Without seeing the foreign key you have no way to distinguish between: There is no associated object (and thus putting a proxy object in place would by simply wrong) or there is one and of which type it is, if inheritance is involved (since putting a proxy of the wrong type in is also wrong).
See discusion on https://github.com/doctrine/orm/issues/4389