I was wondering if there was a reason that the EntityComparisonOperator methods
"compareEqual" and "compareNotEqual" both take a Comparable argument but don't
use that object's compareTo() method - instead they use equals().
I ran into the problem where:
EntityComparisonOperator.compareEqual(BigDecimal.ZERO.setScale(6),
BigDecimal.ZERO)
returns false⦠because BigDecimal's equals() method requires the scale to be
the same.
I believe I encountered this when using a view entity which sums a BigDecimal
column, then trying to filter the results using a condition:
List<EntityCondition> conditionList = Lists.newArrayList();
conditionList.add(EntityCondition.makeCondition("quantityNotAvailable",
EntityOperator.EQUALS, null));
conditionList.add(EntityCondition.makeCondition("quantityNotAvailable",
EntityOperator.EQUALS, BigDecimal.ZERO));
EntityCondition condition =
EntityCondition.makeCondition(quantityNotAvailableConditionList,
EntityOperator.OR);
In the cases where quantityNotAvailable is zero (technically "0.000000"),
EntityCondition.makeCondition("quantityNotAvailable",
EntityOperator.EQUALS, BigDecimal.ZERO)
will return false.