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

DocumentService - load - only detach persisted document if not saved #230

Closed
rsoika opened this issue Nov 5, 2016 · 0 comments
Closed

Comments

@rsoika
Copy link
Member

rsoika commented Nov 5, 2016

In general we detach a document in the load() and getDocumentsByQuery() method. This is for performance reasons and the fact, that a ItemCollection can hold byte arrays which will be copied by reference.

Problem:
In cases where these methods are called after a document was saved - save() method - in one single transaction, the detach call will discard the changes made to the document before in the save() method.

Solution:
For that reason we need to mark a managed document entity in the save() method, so that the methods load() and getDocumentsByQuery() can evaluate this flag. Depending on the state, the methods can decide the correct behavior.

  • In case a document is not flagged (not saved during same transaction), we can still detach the loaded entity
  • In case a document is flagged (saved during save transaction) we may not detach it, but make a deepCopy (clone) of the document instance.

This will avoid the effect, that data written to a document get lost in a long running transaction with save and load calls.

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