You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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).
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:
selectaddresses.id, ... from addresses whereaddresses.user_id=?
If it is the owning side, a join may be required:
selectaddresses.id, ... from addresses inner join users onaddresses.id=users.address_idwhereusers.id=?
For one-to-many collections, a simple select on the target entity table, similar to the following should do:
select .... from phonenumbers ... wherephonenumbers.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.
The text was updated successfully, but these errors were encountered:
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.
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).
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:
If it is the owning side, a join may be required:
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.
The text was updated successfully, but these errors were encountered: