OpenJPA
  1. OpenJPA
  2. OPENJPA-1985

ClassCastException in max(Timestamp) function on PostgreSQL

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.1.0
    • Fix Version/s: 2.1.1, 2.2.0
    • Component/s: jdbc, kernel
    • Labels:
      None
    • Environment:
      Windows 7 x64, Java 1.6.0_25, PostgreSQL 9.0.4 x64, PostgreSQL Native Driver PostgreSQL 9.0 JDBC4 (build 801)

      Description

      Works perfectly in OpenJPA 2.0.1.

      Regression in OpenJPA 2.1.0, 100% reproducible exception.

      Exception:
      SEVERE: Failed to execute query "select max(h.loadTimestamp) from Header h where h.code=?1 and h.period=?2". Check the query syntax for correctness. See nested exception for details.
      <openjpa-2.1.0-r422266:1071316 nonfatal user error>
      org.apache.openjpa.persistence.ArgumentException: Failed to execute query "select max(h.loadTimestamp) from Header h where h.code=?1 and h.period=?2". Check the query syntax for correctness. See nested
      exception for details.
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:872)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
      at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
      at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:305)
      at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:319)
      at org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:343)
      ... my code ...
      Caused by: java.lang.ClassCastException: Cannot convert object
      "2011-04-25 15:48:31+02" of type "class org.postgresql.util.PGobject"
      into an instance of "class java.sql.Timestamp".
      at org.apache.openjpa.kernel.Filters.convert(Filters.java:336)
      at org.apache.openjpa.kernel.Filters.convert(Filters.java:265)
      at org.apache.openjpa.jdbc.kernel.exps.UnaryOp.load(UnaryOp.java:125)
      at org.apache.openjpa.jdbc.kernel.ProjectionResultObjectProvider.getResultObject(ProjectionResultObjectProvider.java:78)
      at org.apache.openjpa.kernel.QueryImpl$PackingResultObjectProvider.getResultObject(QueryImpl.java:2075)
      at org.apache.openjpa.kernel.QueryImpl.singleResult(QueryImpl.java:1330)
      at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1242)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1007)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
      ... 12 more

      Entity:
      @Entity
      @Table(name = "headers")
      @DataCache(enabled = false)
      public class Header

      { @Id @GeneratedValue private long id; @Column(nullable = false) private String code; @Column(nullable = false) private int period; @Column(nullable = false) @Temporal(TemporalType.TIMESTAMP) private Timestamp loadTimestamp; ... }

      Table (autogenerated by OpenJPA 2.0.1):
      create table public.headers (
      id int8 not null,
      loadtimestamp abstime not null,
      period int4 not null,
      code varchar(255) not null,
      primary key (id)
      );

        Issue Links

          Activity

          Stanislav Mironov created issue -
          Michael Dick made changes -
          Field Original Value New Value
          Assignee Michael Dick [ mikedd ]
          Michael Dick made changes -
          Link This issue is related to OPENJPA-1726 [ OPENJPA-1726 ]
          Milosz Tylenda made changes -
          Link This issue relates to OPENJPA-1710 [ OPENJPA-1710 ]
          Michael Dick made changes -
          Fix Version/s 2.2.0 [ 12315910 ]
          Michael Dick made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Michael Dick made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Michael Dick
              Reporter:
              Stanislav Mironov
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development