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

DDC-22: EntityManager#refresh() should also refresh associations. #2894

Closed
doctrinebot opened this issue Sep 25, 2009 · 2 comments
Closed

DDC-22: EntityManager#refresh() should also refresh associations. #2894

doctrinebot opened this issue Sep 25, 2009 · 2 comments

Comments

@doctrinebot
Copy link

Jira issue originally created by user romanb:

Initially this issue was brought up by DC-41 which in turn led to DDC-21. The implementation of DDC-21 requires a working refresh() implementation that also refreshes associations.

  1. For the state of the entity that is refreshed itself this is self-explanatory (simple select on the primary table, this is what already works).

  2. For single-valued associations the proper query depends on whether the entity being refreshed represents the owning side or the inverse side of the association. If it is the inverse side, a simple query like this should do:

select addresses.id, ... from addresses where addresses.user_id=?

If it is the owning side, a join may be required:

select addresses.id, ... from addresses inner join users on addresses.id = users.address_id where users.id=?
  1. For one-to-many collections, a simple select on the target entity table, similar to the following should do:
select .... from phonenumbers ... where phonenumbers.user_id=?

For many-to-many collections a similar select that joins over the join table is required.

An clever way for collections might be to not trigger this SQL immediately on refresh() but to simply mark the collection as uninitialized again so that the first access would trigger the reload, similar to a lazy-load.

Note that the collection itself is refreshed, not the state of the entities contained therein.
Also note that only associations need to be refreshed that were already initialized. If an associated collection is uninitialized, it does not need to be refreshed. If an associated single-valued proxy is uninitialized, it does not need to be refreshed.

@doctrinebot
Copy link
Author

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.0-ALPHA3 milestone Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant