openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fay Wang (JIRA)" <>
Subject [jira] Created: (OPENJPA-1496) Fail to set temporal parameter
Date Fri, 05 Feb 2010 06:02:27 GMT
Fail to set temporal parameter

                 Key: OPENJPA-1496
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
            Reporter: Fay Wang
            Assignee: Fay Wang
             Fix For: 2.1.0

For an entity:

public class TimeEntity {
	private long id;
       String name;
       int value;
       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).

java.lang.IllegalArgumentException: Parameter "Parameter<Calendar>(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(
	at org.apache.openjpa.persistence.QueryImpl.bindValue(
	at org.apache.openjpa.persistence.QueryImpl.setParameter(
	at org.apache.openjpa.persistence.QueryImpl.setParameter(
	at org.apache.openjpa.persistence.QueryImpl.setParameter(
	at d637638.Test637638.testTemporalType(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	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 Source)
	at Source)
	at junit.framework.TestSuite.runTest(Unknown Source)
	at Source)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message