I am using JPA 1.2.1  I have an entity with an update time field of type
Timestamp that is annotated as the version field.  I am trying to create a
query to find all entities of this type that were updated before a certain
time.  When getting the result list from the query, I get an exception.  The
code is as follows:
                String pql = "SELECT s FROM Scenario s WHERE s.updateDateTime < 
:endDate";
                Query queryObj = em.createQuery(pql);
                Timestamp t1 = new Timestamp((new Date()).getTime());
                queryObj.setParameter("endDate", t1);
                List<Scenario> scenarioList = queryObj.getResultList();

The exception is:
<openjpa-1.2.1-SNAPSHOT-r422266:686069 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: Array index out of range:
0
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:857)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:779)
        at
org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:525)
        at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:253)
        at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:293)
        at 
com.citi.rel.domain.scenario.NoteTest.fetchDatedNote(NoteTest.java:70)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
        at java.lang.reflect.Method.invoke(Method.java:599)
        at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
        at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
        at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
        at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        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)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of
range: 0
        at org.apache.openjpa.jdbc.kernel.exps.PCPath.appendTo(PCPath.java:721)
        at
org.apache.openjpa.jdbc.kernel.exps.FilterValueImpl.appendTo(FilterValueImpl.java:63)
        at
org.apache.openjpa.jdbc.kernel.exps.FilterValueImpl.appendTo(FilterValueImpl.java:59)
        at
org.apache.openjpa.jdbc.sql.DBDictionary.comparison(DBDictionary.java:2732)
        at
org.apache.openjpa.jdbc.kernel.exps.CompareExpression.appendTo(CompareExpression.java:75)
        at
org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.buildWhere(SelectConstructor.java:240)
        at
org.apache.openjpa.jdbc.kernel.exps.SelectConstructor.evaluate(SelectConstructor.java:81)
        at
org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.createWhereSelects(JDBCStoreQuery.java:339)
        at
org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeQuery(JDBCStoreQuery.java:179)
        at
org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeQuery(ExpressionStoreQuery.java:681)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:988)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:848)
        ... 32 more


If I change the field to the insert time field, the query works, so it
appears that the problem is that the field is annotated as the Version
field.  Is there any way around this?

Don

-- 
View this message in context: 
http://openjpa.208410.n2.nabble.com/Query-using-timestamp-version-field-tp6076165p6076165.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to