cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: EJBQLQuery with date parameter
Date Mon, 25 Aug 2008 14:21:23 GMT
It's a bug. Let me Jira it and see if we can fix it.

Andrus

On Aug 25, 2008, at 7:26 AM, Steve Wells wrote:

> Just started trying the EJBQLQuery and ran into trouble with date type
> parameters using C3M4, hsql
>
> EJBQLQuery query = new EJBQLQuery("select count(e),
> e.toDocType.marketplaceDocType from EmcTransaction e where " +
>  "e.toReceivedPayload.dateReceived > :fromDate GROUP BY
> e.toDocType.marketplaceDocType");
>  query.setParameter("fromDate", fromDate);
>
> results in:
>
> SELECT COUNT(*) AS sc0, t1.marketplace_doc_type AS sc1 FROM  
> emc_transaction
> t0 INNER JOIN doc_type t1 ON (t0.doc_type_id = t1.id) INNER JOIN
> received_payload t2 ON (t0.received_payload = t2.id) INNER JOIN  
> sent_payload
> t3 ON (t0.sent_payload = t3.id) WHERE t2.date_received > ? GROUP BY
> t1.marketplace_doc_type [bind: 1:'2008-08-25 00:00:00.892']
> 13:32:07,922 94999 INFO
> (org 
> .apache.cayenne.access.QueryLogger.logQueryError(QueryLogger.java: 
> 454))
> - *** error.
> java.lang.IllegalArgumentException: Only DATE, TIME or TIMESTAMP can  
> be
> mapped as 'java.util.Date', got VARBINARY
> at
> org 
> .apache 
> .cayenne 
> .access.types.UtilDateType.convertToJdbcObject(UtilDateType.java:74)
> at
> org 
> .apache 
> .cayenne.access.types.UtilDateType.setJdbcObject(UtilDateType.java: 
> 159)
> at org.apache.cayenne.dba.JdbcAdapter.bindParameter(JdbcAdapter.java: 
> 481)
> at
> org 
> .apache 
> .cayenne.access.jdbc.SQLTemplateAction.bind(SQLTemplateAction.java: 
> 321)
> at
> org 
> .apache 
> .cayenne 
> .access.jdbc.SQLTemplateAction.execute(SQLTemplateAction.java:150)
> at
> org 
> .apache 
> .cayenne 
> .access.jdbc.SQLTemplateAction.performAction(SQLTemplateAction.java: 
> 127)
> at
> org 
> .apache 
> .cayenne.access.jdbc.EJBQLAction.performAction(EJBQLAction.java:100)
> at
> org 
> .apache 
> .cayenne 
> .access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:58)
> at org.apache.cayenne.access.DataNode.performQueries(DataNode.java: 
> 230)
> at
> org 
> .apache 
> .cayenne 
> .access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:424)
> at
> org.apache.cayenne.access.DataDomainQueryAction.access 
> $000(DataDomainQueryAction.java:68)
> at
> org.apache.cayenne.access.DataDomainQueryAction 
> $2.transform(DataDomainQueryAction.java:397)
> at
> org 
> .apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java: 
> 847)
> at
> org 
> .apache 
> .cayenne 
> .access 
> .DataDomainQueryAction 
> .runQueryInTransaction(DataDomainQueryAction.java:394)
> at
> org 
> .apache 
> .cayenne 
> .access.DataDomainQueryAction.execute(DataDomainQueryAction.java:120)
> at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:740)
> at
> org 
> .apache 
> .cayenne 
> .util 
> .ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:317)
> at
> org 
> .apache 
> .cayenne 
> .util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java: 
> 96)
> at org.apache.cayenne.access.DataContext.onQuery(DataContext.java: 
> 1336)
> at
> org.apache.cayenne.access.DataContext.performQuery(DataContext.java: 
> 1325)
>
> The field date_received is definatly TIMESTAMP type 93.
>
> Any help appreciated.  Am I better for a while sticking with  
> SQLTemplate?
>
> Thanks,
>
> Steve


Mime
View raw message