Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SecondLevelCache throws exception when there's a not cached relation in the entity #11258

Open
KDederichs opened this issue Feb 13, 2024 · 0 comments

Comments

@KDederichs
Copy link

Bug Report

Q A
BC Break no
Version 2.18.0

Summary

When you have a cached entity that references a non cached entity, you'll get an exception.

Current behavior

Trying to call any find method on the entity repository of the cached entity will result in:

In DefaultQueryCache.php line 340:
                                                                                                                                
  Attempted to call an undefined method named "getCacheRegion" of class "Doctrine\ORM\Persisters\Entity\BasicEntityPersister".  

How to reproduce

#[Entity(repositoryClass: FooRepository::class)]
#[Cache(usage: 'NONSTRICT_READ_WRITE', region: 'write_rare')]
class Foo {
    #[Id]
    #[Column(type: UuidType::NAME)]
    private Uuid $id;

    #[OneToOne(mappedBy: 'foo', targetEntity: Bar::class, fetch: 'EXTRA_LAZY')]
    private ?Bar $bar = null;
}

#[Entity(repositoryClass: BarRepository::class)]
class Bar {
    #[Id]
    #[Column(type: UuidType::NAME)]
    private Uuid $id;

    #[OneToOne(inversedBy: 'bar', targetEntity: Foo::class)]
    #[JoinColumn(nullable: false, onDelete: 'CASCADE')]
    private Foo $foo;
}

Now call for example findAll() on FooRepository

Expected behavior

No exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant