-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
ListCompareAlgorithm.AS_SET not working in combination with CustomComparator #832
Comments
simple but slow implementation (n-squared)
Fixed in 5.7.4 Added possibility to use Warning! The list comparing algorithm would be slow in this case for large lists because it has n2 complexity |
Thanks for fixing this issue. Unfortunately it is not working in my case with Javers Version 5.7.4 I have my test case attached. I am using the org.javers.core.diff.custom.CustomBigDecimalComparator. The testWithSet is not working. |
@buderjoh push your code to github as a runnable test case, see https://github.com/javers/javers/blob/master/CONTRIBUTING.md#guidelines-for-bug-reporting |
The testcase is included in the branch -> https://github.com/buderjoh/javers/tree/javers-832 Both testcases should work... The testWithSet is not working. |
Your second case is different. Issue happens when you compare List of ValueObjects using AS_SET and one of fields in this ValueObject is a CustomType. Remember that CustomTypes don't have valid hashCode() so also your ValueObject (Floor) dosn't have a valid hashCode(). Comparing Sets without hashCode() would be very slow for large Sets (n-squared complexity) |
In 5.8.1, Custom comparators are reinvented, now your case should work. See https://javers.org/release-notes |
It works thanks :) |
If you use
JaversBuilder.javers().withListCompareAlgorithm(ListCompareAlgorithm.AS_SET)
.registerCustomComparator(new CustomBigDecimalComparator(2), BigDecimal.class);
The CustomBigDecimalComparator is not invoked.
JaversBuilder.javers().registerCustomComparator(new CustomBigDecimalComparator(2), BigDecimal.class);
is working and CustomBigDecimalComparator is invoked.
The text was updated successfully, but these errors were encountered: