From dev-return-14986-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Tue Feb 09 07:49:49 2010 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 70904 invoked from network); 9 Feb 2010 07:49:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Feb 2010 07:49:49 -0000 Received: (qmail 27506 invoked by uid 500); 9 Feb 2010 07:49:48 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 27433 invoked by uid 500); 9 Feb 2010 07:49:48 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 27423 invoked by uid 99); 9 Feb 2010 07:49:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Feb 2010 07:49:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Feb 2010 07:49:47 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id CEE78234C045 for ; Mon, 8 Feb 2010 23:49:27 -0800 (PST) Message-ID: <1734499697.143031265701767831.JavaMail.jira@brutus.apache.org> Date: Tue, 9 Feb 2010 07:49:27 +0000 (UTC) From: "Fay Wang (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-1496) Fail to set temporal parameter In-Reply-To: <1561474266.60581265349747825.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OPENJPA-1496?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fay Wang updated OPENJPA-1496: ------------------------------ Attachment: OPENJPA-1496-3.patch > Fail to set temporal parameter > ------------------------------ > > Key: OPENJPA-1496 > URL: https://issues.apache.org/jira/browse/OPENJPA-1496 > Project: OpenJPA > Issue Type: Bug > Components: jdbc > Reporter: Fay Wang > Assignee: Fay Wang > Fix For: 2.1.0 > > Attachments: OPENJPA-1496-2.patch, OPENJPA-1496-3.patch, OPENJPA-1496.patch > > > For an entity: > @Entity > public class TimeEntity { > @Id > @GeneratedValue > private long id; > > String name; > > int value; > > @Temporal(TemporalType.TIMESTAMP) > private java.util.Calendar cal2Timestamp; > ...} > an attempt to set parameter as below fails with IllegalArgumentException: > String jpql = "SELECT COUNT(a) FROM TimeEntity a WHERE a.cal2Timestamp BETWEEN ?1 AND ?2"; > Calendar endTime = Calendar.getInstance(); > Calendar startTime = (Calendar)endTime.clone(); > startTime.add(14, -4); > List results = em.createQuery(jpql). > setParameter(1, startTime, TemporalType.TIMESTAMP). > setParameter(2, endTime, TemporalType.TIMESTAMP). > getResultList(); > java.lang.IllegalArgumentException: Parameter "Parameter(2)" declared in "SELECT COUNT(a) FROM TimeEntity a WHERE a.value = ?1 AND a.cal2Timestamp BETWEEN ?2 AND ?3" is set to value of "2/4/10 9:55 PM" of type "java.sql.Timestamp", but this parameter is bound to a field of type "java.util.Calendar". > at org.apache.openjpa.persistence.QueryImpl.assertValueAssignable(QueryImpl.java:1079) > at org.apache.openjpa.persistence.QueryImpl.bindValue(QueryImpl.java:1036) > at org.apache.openjpa.persistence.QueryImpl.setParameter(QueryImpl.java:640) > at org.apache.openjpa.persistence.QueryImpl.setParameter(QueryImpl.java:653) > at org.apache.openjpa.persistence.QueryImpl.setParameter(QueryImpl.java:1) > at d637638.Test637638.testTemporalType(Test637638.java:36) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at junit.framework.TestCase.runTest(Unknown Source) > at junit.framework.TestCase.runBare(Unknown Source) > at junit.framework.TestResult$1.protect(Unknown Source) > at junit.framework.TestResult.runProtected(Unknown Source) > at junit.framework.TestResult.run(Unknown Source) > at junit.framework.TestCase.run(Unknown Source) > at junit.framework.TestSuite.runTest(Unknown Source) > at junit.framework.TestSuite.run(Unknown Source) > at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) > at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45) > at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.