Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-5845 - Lazy loading of audited entites with revision type DEL
- Loading branch information
1 parent
8eeef7a
commit 8342194
Showing
29 changed files
with
1,147 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
8342194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasz-antoniak,
I think this fix causes problem if you have a collection relationship allowing duplicates. The reason for this is that the querygenerators creates a OR clause between "valid" and "removed", which possible creates duplicate records (both last valid and removed). The tests are usings sets however so these duplicates will effectively be invisible in the collections and the tests written are therefore green.
To make it green also for eg bag or list semantic, the correct way, I guess, for finding the association would be to ...
...for DefaultAuditStrategy
put the OR clause within the select max(rev)... subquery.
...for ValidityAuditStrategy
A subquery must be introduced here as well. This subquery should find the "highest" revision of the "valid" or "removed" revision.
Regards
Roger
8342194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasz-antoniak
FWIW, I committed a patch for above in NHibernate Envers. Available here
https://bitbucket.org/RogerKratz/nhibernate.envers/commits/7cc2b52e52edf8d7913d53bfc98be9656946758e
Feel free to use it if you agree on it.
The change made is to always call auditStrategy.AddEntityAtRevisionRestriction with inclusive=true. If not, duplicated elements (may be) returned when fetching relationship data.
8342194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RogerKratz: Thank you for pointing this. Your fix to
OneAuditEntityQueryGenerator
andTwoEntityQueryGenerator
seems fine. I would propose a different solution toThreeEntityQueryGenerator
, refer to my forked branch commit: lukasz-antoniak@c8ffe6a#L1L191. IMO there was a more serious defect generating wrong WHERE clause for ternary maps.@adamw: Can you have a look? I did not touch
ThreeEntityQueryGenerator
before. All test pass.8342194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasz-antoniak: I'm on vacation right now with no "development environment" so I cannot really have a good look at your fix for ThreeEntityQueryGenerator. But, by looking at the code at Github, I get the impression that your fix fixes something else then the original problem (possible duplicate elements). Right?
8342194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RogerKratz: Yes, it does. My modification fixes ternary map use case when user modifies the key of map value. IMO it did not work well before. I failed to reproduce duplicate elements generation while traversing DEL state (issue you reported), so would be grateful if you could double-check my patch from NHibernate side.
8342194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasz-antoniak
I think your fix in ThreeEntityQueryGenerator doesn't fix the issue I mentioned. If I, in NHibernate Envers, skip the fix I did, the test https://bitbucket.org/RogerKratz/nhibernate.envers/commits/7cc2b52e52edf8d7913d53bfc98be9656946758e#chg-Src/NHibernate.Envers.Tests/NetSpecific/Integration/Proxy/MapRemovedObjectQueryTest.cs
fails.
The fix you did in ThreeEntityQueryGenerator may very well be needed as well, but I think both are needed.
8342194
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't read the whole code as it's a lot, but things to check (maybe they are already checked):
If the tests pass, it looks good :)