You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Paulo Leal <pa...@gmail.com> on 2012/12/07 13:10:10 UTC

ArrayIndexOutOfBoundsException on query

Running a query I get a message: *openjpa.Runtime: Warn: Supplied user
parameters "[1, 2, 3, 4, 5]" do not match expected parameters "[1, 1, 2, 3,
4, 5]" for the prepared query *
*
*
*the query is like*
*SELECT *
*    test *
*FROM *
*    com.phleal.persistence.model.Test test *
*WHERE *
*    EXISTS (*
*SELECT attr*
*FROM com.phleal.persistence.model.TestAttribute attr*
*WHERE attr.test = test AND attr.namespace.namespaceURI = ?1 AND
attr.name= ?2 AND ( ( attr.valueTypeId = ?3 AND attr.stringValue = ?4
) )
*
*     )*
*     AND ?5 MEMBER OF reg.testTypes*
*     AND reg.testCompleted = false*



 After this Warning I get an ArrayIndexOutOfBoundsException:




*Failed to execute query SELECT *
*    test *
*FROM *
*    com.phleal.persistence.model.Test test *
*WHERE *
*    EXISTS (*
*SELECT attr*
*FROM com.phleal.persistence.model.TestAttribute attr*
*WHERE attr.test = test AND attr.namespace.namespaceURI = ?1 AND
attr.name= ?2 AND ( ( attr.valueTypeId = ?3 AND attr.stringValue = ?4
) )
*
*     )*
*     AND ?5 MEMBER OF reg.testTypes*
*     AND reg.testCompleted = false". Check the query syntax for
correctness. See nested exception for details..*
*                                 <openjpa-2.2.1-SNAPSHOT-r422266:1325904
nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
Failed to execute query "SELECT *
*    test *
*FROM *
*    com.phleal.persistence.model.Test test *
*WHERE *
*    EXISTS (*
*SELECT attr*
*FROM com.phleal.persistence.model.TestAttribute attr*
*WHERE attr.test = test AND attr.namespace.namespaceURI = ?1 AND
attr.name= ?2 AND ( ( attr.valueTypeId = ?3 AND attr.stringValue = ?4
) )
*
*     )*
*     AND ?5 MEMBER OF reg.testTypes*
*     AND reg.testCompleted = false". 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:286)*
* at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)*
* at
com.phleal.persistence.TestManager.getRelatedTest(TestManager.java:1794)*
*.*
*.*
*.*
*
*
* at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)*
* at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
*
* at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)*
* at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783)*
*Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of
range: 5*
* at
org.apache.openjpa.jdbc.kernel.PreparedSQLStoreQuery$PreparedSQLExecutor.toParameterArray(PreparedSQLStoreQuery.java:161)
*
* at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:857)*
* ... 89 more*


I am sure I only pass 5 attributes to the query, I don't know what could
generate the "[1, 1, 2, 3, 4, 5]" from the message.
I am running this query on multiple threads, and it is quite intermittent.

Re: ArrayIndexOutOfBoundsException on query

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Paulo,
This scenario sounds so familiar, but I can't seem to find a corresponding
JIRA for the problem...  If I remember right, issues like this are usually
related to the prepared sql cache and how the parameters are processed.  As
a quick test/workaround, you could try turning off this cache to see if you
make more progress:

<property name="openjpa.jdbc.QuerySQLCache" value="false">

Good luck,
Kevin


On Fri, Dec 7, 2012 at 6:10 AM, Paulo Leal <pa...@gmail.com> wrote:

> Running a query I get a message: *openjpa.Runtime: Warn: Supplied user
> parameters "[1, 2, 3, 4, 5]" do not match expected parameters "[1, 1, 2, 3,
> 4, 5]" for the prepared query *
> *
> *
> *the query is like*
> *SELECT *
> *    test *
> *FROM *
> *    com.phleal.persistence.model.Test test *
> *WHERE *
> *    EXISTS (*
> *SELECT attr*
> *FROM com.phleal.persistence.model.TestAttribute attr*
> *WHERE attr.test = test AND attr.namespace.namespaceURI = ?1 AND
> attr.name= ?2 AND ( ( attr.valueTypeId = ?3 AND attr.stringValue = ?4
> ) )
> *
> *     )*
> *     AND ?5 MEMBER OF reg.testTypes*
> *     AND reg.testCompleted = false*
>
>
>
>  After this Warning I get an ArrayIndexOutOfBoundsException:
>
>
>
>
> *Failed to execute query SELECT *
> *    test *
> *FROM *
> *    com.phleal.persistence.model.Test test *
> *WHERE *
> *    EXISTS (*
> *SELECT attr*
> *FROM com.phleal.persistence.model.TestAttribute attr*
> *WHERE attr.test = test AND attr.namespace.namespaceURI = ?1 AND
> attr.name= ?2 AND ( ( attr.valueTypeId = ?3 AND attr.stringValue = ?4
> ) )
> *
> *     )*
> *     AND ?5 MEMBER OF reg.testTypes*
> *     AND reg.testCompleted = false". Check the query syntax for
> correctness. See nested exception for details..*
> *                                 <openjpa-2.2.1-SNAPSHOT-r422266:1325904
> nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
> Failed to execute query "SELECT *
> *    test *
> *FROM *
> *    com.phleal.persistence.model.Test test *
> *WHERE *
> *    EXISTS (*
> *SELECT attr*
> *FROM com.phleal.persistence.model.TestAttribute attr*
> *WHERE attr.test = test AND attr.namespace.namespaceURI = ?1 AND
> attr.name= ?2 AND ( ( attr.valueTypeId = ?3 AND attr.stringValue = ?4
> ) )
> *
> *     )*
> *     AND ?5 MEMBER OF reg.testTypes*
> *     AND reg.testCompleted = false". 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:286)*
> * at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)*
> * at
> com.phleal.persistence.TestManager.getRelatedTest(TestManager.java:1794)*
> *.*
> *.*
> *.*
> *
> *
> * at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)*
> * at
>
> com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
> *
> * at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)*
> * at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783)*
> *Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of
> range: 5*
> * at
>
> org.apache.openjpa.jdbc.kernel.PreparedSQLStoreQuery$PreparedSQLExecutor.toParameterArray(PreparedSQLStoreQuery.java:161)
> *
> * at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:857)*
> * ... 89 more*
>
>
> I am sure I only pass 5 attributes to the query, I don't know what could
> generate the "[1, 1, 2, 3, 4, 5]" from the message.
> I am running this query on multiple threads, and it is quite intermittent.
>