Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-1932

Improved Handling for Scalar Parameters Converting Expressions to EJBQL

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.M1
    • 4.0.M2
    • Core Library
    • None

    Description

      The "toEJBQL()" method on the Expression object works well for some cases, but fails where parameter types are employed where there is no EJBQL literal that can be used to serialize the object as a string in the resultant EJBQL string.

      An obvious case of this is the use of a Date object. Take the example of a comparison between an object path and a date parameter. The current code is outputting something like;

      (a.something.createTimestamp > 25 Mar 2014 12:23:34)
      

      This "toString" on the Date object does not generate valid EJBQL and as far as I am able to ascertain, there is no timestamp literal in EJBQL. For this reason, the "toEJBQL()" method on Expression is able to generate broken EJBQL strings.

      My solution to this will be to keep the existing "toEJBQL()" method, but have that method fail with a runtime exception if it encounters a situation in which it is not able to serialize to EJBQL correctly. Another method "toEJBQL(List<Object> parameterAccumulator)" will be provided. This new method will populate the parameter accumulator each time it encounters a parameter that it is not able to express as a literal and instead it will use a positional parameter in the EJBQL string. The caller can then use the 'captured' parameters to feed back into the EJBQLQuery object.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            apl Andrew Ponsonby Lindesay
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment