Skip to content

Lazy Fields automatically create Partial Objects omitting columns from initial load. #12258

@beberlei

Description

@beberlei

With native lazy loading support and partial objects as lazy objects, another feature that we could "easily" implement is marking columns as lazy, which would automatically make an entity a partial object.

<?php

#[Entity]
class Post
{
    #[Id, GeneratedValue, Column(type: Types::INTEGER)]
    public int $id;
    #[Column]
    public string $title;
    #[Column, Lazy]
    public string $body;
}

$post = $entityManager->find(Post::class, 1);
echo $post->title; // direct access
echo $post->body; // triggers lazy loading SELECT body FROM post WHERE id = 1

This also requires a way to specify that an object should be "FULLY" loaded from the beginning, i don't. have a complete idea on how to do that, multiple options:

  1. DQL keyword SELECT FULL p FROM Post p
  2. Allow passing $hints to finder methods, $entityManager->find(1, hints: [Query::HINT_FORCE_FULL_LOAD => true]) or ssomething similar.

Related:

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