Skip to content

Multiple entity managers and shared entities management #12320

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

Closed
wants to merge 1 commit into from

Conversation

ipernet
Copy link

@ipernet ipernet commented Sep 15, 2019

Multiple entity manager doc improvement related to the discussion With multiple Entity Managers (EM) the Repository uses only the mapped EM for the Entity (#9878)

@ipernet ipernet requested a review from xabbuh as a code owner September 15, 2019 10:50
@ipernet ipernet changed the base branch from 4.2 to master September 15, 2019 10:52
@ipernet ipernet force-pushed the multiple-entity-managers branch 4 times, most recently from 940d21c to ae1cb13 Compare September 15, 2019 10:59
@ipernet ipernet force-pushed the multiple-entity-managers branch from ae1cb13 to b549b46 Compare September 15, 2019 11:13
@wouterj
Copy link
Member

wouterj commented Oct 3, 2020

Hi @ipernet! I'm sorry you didn't receive any comment from us on this PR. It's quite a difficult topic and quite a big diff, seems like we all somehow lost this PR..

Do you have any motivation to work on this PR? If so, I would like to say some comments on how to improve this:

I think we should make this more concise. We don't have to show all different ways to get the repository - that'll only confuse the user ("which one is the correct/recommended way?"). I think the most important thing here is that you can't use ServiceEntityRepository if the entity is managed by more than one entity manager - it'll always default to the first configured entity manager. The solution is to use EntityRepository and not use autowiring. I think we can say all this in a .. caution:: directive after line 256 (so keep your changes till line 256, then tell what doesn't work (ServicEntityRepository with an entity managed by multiple managers) and then show the EntityRepository code example of 558 - 567).

I can also imagine if you no longer have time to work on this PR, please say so then I can take over and make the necessary changes. Seems like there are quite some users running into this issue.

@ipernet
Copy link
Author

ipernet commented Oct 4, 2020

Hi @wouterj

I can still provide support on this PR, I'll have a look later in the day about your feedback, for a start!

@ipernet
Copy link
Author

ipernet commented Oct 4, 2020

Hi @wouterj

Based on the current documentation, your feedback is about adding a single warning, as you explained it very well:

"You can't use ServiceEntityRepository if the entity is managed by more than one entity manager - it'll always default to the first configured entity manager. The solution is to use EntityRepository and not use autowiring.

But this would mean that no further details (rather than just showing a basic EntityRepository class) would be provided to the users reading the doc, while the main purpose of the proposed changes was indeed to provide a deeper understanding of what remains an advanced usage of entity managers for users who opened/follow issues related to the lack of documentation on the subject.

So I would suggest to add the notice on top of the existing doc then close the PR without merging. It will still be a reference for those digging in the related issues.

@wouterj
Copy link
Member

wouterj commented Oct 4, 2020

Hi @ipernet. Thanks for your quick responses.

I have never been in a situation with multiple entity managers (let alone having an entity in multiple managers). Do you, with your experience, think that it's enough to add the small note or would that not have helped you in the situation you had a year ago?
We (of course) try to keep the docs small (nobody likes reading), but we shouldn't make this so small that it becomes useless (current situation).

@ipernet
Copy link
Author

ipernet commented Oct 4, 2020

@wouterj Yes, the main issue to me was to understand that a ServiceEntityRepository only uses the first configured EntityManager. Adding a small note mentioning it and the use of an EntityRepository as a workaround as well would be a time saver without making the doc too coumbersome.

@wouterj
Copy link
Member

wouterj commented Oct 4, 2020

Thanks for your feedback again!

I've created a new PR based on your commit: #14336 This way, I can still give you the credits you deserved (this PR was copy/pasting your examples)!

@wouterj wouterj closed this Oct 4, 2020
javiereguiluz added a commit that referenced this pull request Oct 7, 2020
…ed by multiple managers (Guillaume)

This PR was merged into the 4.4 branch.

Discussion
----------

[Doctrine] Add caution about a single entity being managed by multiple managers

Fixes #9878

This continues the great work done in #12320 by @ipernet .

Commits
-------

de39e50 Multiple entity managers and shared entities management
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants