Uploaded image for project: 'Hibernate ORM'
  1. HHH-9869

SizeExpression toString is misleading

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.0.CR1
    • Fix Version/s: 5.0.0.CR4, 4.3.11
    • Component/s: hibernate-core
    • Labels:
      None
    • Suitable for new contributors:
      Yes, likely
    • Last commented by a user?:
      true
    • Sprint:

      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:

      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());
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - Not Specified
                Not Specified
                Logged:
                Time Spent - 5m
                5m