We're updating the issue view to help you get more done. 

SizeExpression toString is misleading

Description

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:

1 assertEquals("prop.size>=1", Restrictions.sizeGe("prop", 1).toString());

However it fails with:

1 2 3 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:

1 assertEquals("1<=prop.size", Restrictions.sizeGe("prop", 1).toString());

Environment

None

Status

Assignee

Steve Ebersole

Reporter

Peter

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

5.0.0.CR1

Priority

Minor