Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2861

select sum(CASE x WHEN x THEN 1 ELSE 0 ) returns String instead of Long.

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.2
    • 3.2.0
    • kernel
    • None

    Description

      It seems that a few operations in JDBCExpressionFactory often calls getLiteralRawString which destroys the information about any real types in a query and replaces it with a Raw which is always of type java.lang.String.

      This breaks the following query, which wrongly returns a string instead of a Long:

      final TypedQuery<Long> q 
         = em.createQuery("select SUM(CASE ae.stringVal WHEN 'bare' THEN 1 ELSE 0 END) from AggEntity AS ae", Long.class);
      final Long sumC = q.getSingleResult();

      This only affects us since I fixed UnaryOp to not return the native JDBC vendor type of a given column but uses the val.getType()

      Attachments

        Activity

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

          People

            struberg Mark Struberg
            struberg Mark Struberg
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment