Skip to content

Throw exception in getManagerForClass when multiple entity managers manage the same entity #68

Description

@alcaeus

This came to me while reading through symfony/symfony-docs#9878. In a few of those cases, people have the same entity managed by multiple entity managers. While I'm not sure whether that constitutes a valid use-case, the manager registry is equipped to handle this by allowing to specify en entity manager to use when calling AbstractManagerRegistry::getRepository.

However, AbstractManagerRegistry::getManagerForClass handles those cases wrong IMO: it simply returns the first entity manager that manages the entity in question. In cases like the above, this can lead to undesired behaviour as we're ignoring the fact that we can't reliably say which entity manager is responsible for.a given class.

Assuming the use-case of having the same entity managed by multiple entity managers is valid, we should throw an exception in getManagerForClass if we realise that the same class is managed by more than a single entity manager.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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