Skip to content

OneToOne fetch="EAGER" not working #81

Description

@KristijanKanalas

What is this feature about (expected vs actual behaviour)?

How my code looks:

    /**
     * @ORM\OneToOne(targetEntity="App\Entity\entityY", mappedBy="entityX", fetch="EAGER")
     * @ORM\JoinColumn(name="entityYId", referencedColumnName="id")
     * @var entityY
     */
    private $entityY;

Expected behaviour would be to load data in $Y before I try to access it but the actual thing that is happening is that I am getting a null value in that field.

If I am not using fetch="EAGER" it defaults to fetch="LAZY" which works fine and i do end up having an entity App\Entity\Y in $Y.

How can I reproduce it?

Just make two entities that have OneToOne relationship and in one table put a code similar to this:

    /**
     * @ORM\OneToOne(targetEntity="App\Entity\Y", mappedBy="X", fetch="EAGER")
     * @ORM\JoinColumn(name="XId", referencedColumnName="Yid")
     * @var Y
     */
    private $Y;

Does it take minutes, hours or days to fix?

I am not sure how long it would take to fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions