openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stanislav Mironov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (OPENJPA-1985) ClassCastException in max(Timestamp) function on PostgreSQL
Date Tue, 26 Apr 2011 12:44:03 GMT
ClassCastException in max(Timestamp) function on PostgreSQL
-----------------------------------------------------------

                 Key: OPENJPA-1985
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1985
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc, kernel
    Affects Versions: 2.1.0
         Environment: Windows 7 x64, Java 1.6.0_25, PostgreSQL 9.0.4 x64, PostgreSQL Native
Driver PostgreSQL 9.0 JDBC4 (build 801)
            Reporter: Stanislav Mironov
            Priority: Blocker
             Fix For: 2.1.1


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


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message