glassfish
  1. glassfish
  2. GLASSFISH-3765

Postgres does not support truncateDate in Expression Builder

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 9.1pe
    • Fix Version/s: not determined
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      3,765
    • Status Whiteboard:
      Hide

      as91ur1-na as911-na

      Show
      as91ur1-na as911-na

      Description

      When running against Postgres, and using the ExpressionBuilder, the truncateDate
      function/operator is not implemented.

      I have managed to workaround it by implementing a subclass of the
      PostgresSQLPlatform, and then specifying it in my persistence.properties file.
      You are free to use this code directly, or as an inspiration to a more correct fix.

      public class PostgresPlatform extends
      oracle.toplink.essentials.platform.database.PostgreSQLPlatform {

      /** Creates a new instance of PostgresPlatform */
      public PostgresPlatform()

      { super(); }

      protected void initializePlatformOperators()

      { super.initializePlatformOperators(); addOperator(postgresTruncOperator()); }

      public ExpressionOperator postgresTruncOperator()

      { ExpressionOperator op = ExpressionOperator.simpleTwoArgumentFunction(ExpressionOperator.TruncateDate, "date_trunc"); int indices[] = new int[2]; indices[0] = 1; indices[1] = 0; op.setArgumentIndices(indices); return op; }

      }

      I'm hoping someone can verify this and roll it in to the distribution. Postgres
      appears to support pretty much the same date parts as Oracle, but I know there
      is no standard for the actual date parts. I think a better solution might be to
      standardize on Oracles "parts", and map them to the Postgres parts. The big ones
      (month, day, year, hour, minute, second) match.

      I had a devil of a time trying to figure out how to swap the parameters in the
      generated SQL.

        Activity

        Hide
        gfbugbridge added a comment -

        <BT6616576>

        Show
        gfbugbridge added a comment - <BT6616576>
        Hide
        tware added a comment -

        Updated target milestone

        Show
        tware added a comment - Updated target milestone
        Hide
        Mitesh Meswani added a comment -

        Will not be fixed for V2.1

        Show
        Mitesh Meswani added a comment - Will not be fixed for V2.1
        Hide
        sanandal added a comment -

        "Reclassifying as P4 because this issue is not deemed "must fix" for this v2.1
        release whose primary release driver is SailFin.
        This issue will be scrubbed after this release and will be given the right
        priority for the next release."

        Show
        sanandal added a comment - "Reclassifying as P4 because this issue is not deemed "must fix" for this v2.1 release whose primary release driver is SailFin. This issue will be scrubbed after this release and will be given the right priority for the next release."
        Hide
        Tom Mueller added a comment -

        Bulk change to set fix version to "not determined" where the issue is open but the value is for a released version.

        Show
        Tom Mueller added a comment - Bulk change to set fix version to "not determined" where the issue is open but the value is for a released version.

          People

          • Assignee:
            tware
            Reporter:
            whartung
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: