|
SizeExpression's toString method outputs misleading results.
The toString implementation assumes that the implementation has the computed size on the LHS whereas toSqlString (and accordingly the op that is passed by the Restrictions.sizeXX methods) is implemented with the computed size on the RHS.
This leads to confusing results for users when printing out criterion.toString values, as they appear to be saying roughly the opposite of what they are being asked to do.
As a user I would expect the following test to pass:
assertEquals("prop.size>=1", Restrictions.sizeGe("prop", 1).toString());
However it fails with:
org.junit.ComparisonFailure:
Expected :prop.size>=1
Actual :prop.size<=1
The lowest impact change would be to alter toString to emit the same order as toSqlString, so the following test would pass:
assertEquals("1<=prop.size", Restrictions.sizeGe("prop", 1).toString());
|