org.springframework.data.repository.query.ParameterOutOfBoundsException: Invalid parameter index! You seem to have declare too little query method parameters!

Spring JIRA | Colin McQueen | 3 years ago
  1. 0

    I tried creating a repository method with parameters but it seems that it doesn't work. This is the following query I wanted: {code} @Query(SELECT * FROM foo WHERE p1 = :p1 AND p2 = :p2 AND p3 = :p3) Set<Foo> findByPartitionKey(@Param("p1") final double p1, @Param("p2") final double p2, @Param("p3") final String p3); {code} Here is the stacktrace for the above query: {code} com.datastax.driver.core.exceptions.InvalidQueryException: Invalid amount of bind variables at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:35) at com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException(ResultSetFuture.java:269) at com.datastax.driver.core.ResultSetFuture.getUninterruptibly(ResultSetFuture.java:183) at com.datastax.driver.core.Session.execute(Session.java:111) at org.springframework.cassandra.core.CqlTemplate$12.doInSession(CqlTemplate.java:519) at org.springframework.cassandra.core.CqlTemplate$12.doInSession(CqlTemplate.java:510) at org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:487) at org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:510) at org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:499) at org.springframework.cassandra.core.CqlTemplate.query(CqlTemplate.java:409) at org.springframework.cassandra.core.CqlTemplate.query(CqlTemplate.java:436) at org.springframework.cassandra.core.CqlTemplate.query(CqlTemplate.java:430) at org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:122) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy1408.findByPartitionKey(Unknown Source) {code} Also tried indexes instead of bind parameter names {code} @Query(SELECT * FROM foo WHERE p1 = ?1 AND p2 = ?2 AND p3 = ?3) Set<Foo> findByPartitionKey(final double p1, final double p2, final String p3); {code} The above query gave me the following stacktrace: {code} org.springframework.data.repository.query.ParameterOutOfBoundsException: Invalid parameter index! You seem to have declare too little query method parameters! at org.springframework.data.repository.query.Parameters.getParameter(Parameters.java:179) at org.springframework.data.repository.query.Parameters.getBindableParameter(Parameters.java:249) at org.springframework.data.repository.query.ParametersParameterAccessor.getBindableValue(ParametersParameterAccessor.java:107) at org.springframework.data.cassandra.repository.query.StringBasedCassandraQuery.getParameterWithIndex(StringBasedCassandraQuery.java:48) at org.springframework.data.cassandra.repository.query.StringBasedCassandraQuery.replacePlaceholders(StringBasedCassandraQuery.java:41) at org.springframework.data.cassandra.repository.query.StringBasedCassandraQuery.createQuery(StringBasedCassandraQuery.java:30) at org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:120) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy1486.findByPartitionKey(Unknown Source) Caused by: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3 at java.util.ArrayList.rangeCheck(ArrayList.java:635) at java.util.ArrayList.get(ArrayList.java:411) at org.springframework.data.repository.query.Parameters.getParameter(Parameters.java:177) ... 38 more {code}

    Spring JIRA | 3 years ago | Colin McQueen
    org.springframework.data.repository.query.ParameterOutOfBoundsException: Invalid parameter index! You seem to have declare too little query method parameters!
  2. 0

    I tried creating a repository method with parameters but it seems that it doesn't work. This is the following query I wanted: {code} @Query(SELECT * FROM foo WHERE p1 = :p1 AND p2 = :p2 AND p3 = :p3) Set<Foo> findByPartitionKey(@Param("p1") final double p1, @Param("p2") final double p2, @Param("p3") final String p3); {code} Here is the stacktrace for the above query: {code} com.datastax.driver.core.exceptions.InvalidQueryException: Invalid amount of bind variables at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:35) at com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException(ResultSetFuture.java:269) at com.datastax.driver.core.ResultSetFuture.getUninterruptibly(ResultSetFuture.java:183) at com.datastax.driver.core.Session.execute(Session.java:111) at org.springframework.cassandra.core.CqlTemplate$12.doInSession(CqlTemplate.java:519) at org.springframework.cassandra.core.CqlTemplate$12.doInSession(CqlTemplate.java:510) at org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:487) at org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:510) at org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:499) at org.springframework.cassandra.core.CqlTemplate.query(CqlTemplate.java:409) at org.springframework.cassandra.core.CqlTemplate.query(CqlTemplate.java:436) at org.springframework.cassandra.core.CqlTemplate.query(CqlTemplate.java:430) at org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:122) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy1408.findByPartitionKey(Unknown Source) {code} Also tried indexes instead of bind parameter names {code} @Query(SELECT * FROM foo WHERE p1 = ?1 AND p2 = ?2 AND p3 = ?3) Set<Foo> findByPartitionKey(final double p1, final double p2, final String p3); {code} The above query gave me the following stacktrace: {code} org.springframework.data.repository.query.ParameterOutOfBoundsException: Invalid parameter index! You seem to have declare too little query method parameters! at org.springframework.data.repository.query.Parameters.getParameter(Parameters.java:179) at org.springframework.data.repository.query.Parameters.getBindableParameter(Parameters.java:249) at org.springframework.data.repository.query.ParametersParameterAccessor.getBindableValue(ParametersParameterAccessor.java:107) at org.springframework.data.cassandra.repository.query.StringBasedCassandraQuery.getParameterWithIndex(StringBasedCassandraQuery.java:48) at org.springframework.data.cassandra.repository.query.StringBasedCassandraQuery.replacePlaceholders(StringBasedCassandraQuery.java:41) at org.springframework.data.cassandra.repository.query.StringBasedCassandraQuery.createQuery(StringBasedCassandraQuery.java:30) at org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:120) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy1486.findByPartitionKey(Unknown Source) Caused by: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3 at java.util.ArrayList.rangeCheck(ArrayList.java:635) at java.util.ArrayList.get(ArrayList.java:411) at org.springframework.data.repository.query.Parameters.getParameter(Parameters.java:177) ... 38 more {code}

    Spring JIRA | 3 years ago | Colin McQueen
    org.springframework.data.repository.query.ParameterOutOfBoundsException: Invalid parameter index! You seem to have declare too little query method parameters!
  3. 0

    java.lang.IndexOutOfBoundsException error

    GitHub | 3 years ago | Anxulite
    java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Error on ArrayList

    Stack Overflow | 3 years ago | HansFrank
    java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IndexOutOfBoundsException

    Index: 3, Size: 3

    at java.util.ArrayList.rangeCheck()
  2. Java RT
    ArrayList.get
    1. java.util.ArrayList.rangeCheck(ArrayList.java:635)
    2. java.util.ArrayList.get(ArrayList.java:411)
    2 frames
  3. Spring Data Core
    ParametersParameterAccessor.getBindableValue
    1. org.springframework.data.repository.query.Parameters.getParameter(Parameters.java:177)
    2. org.springframework.data.repository.query.Parameters.getParameter(Parameters.java:179)
    3. org.springframework.data.repository.query.Parameters.getBindableParameter(Parameters.java:249)
    4. org.springframework.data.repository.query.ParametersParameterAccessor.getBindableValue(ParametersParameterAccessor.java:107)
    4 frames
  4. Spring Data Cassandra - Core
    AbstractCassandraQuery.execute
    1. org.springframework.data.cassandra.repository.query.StringBasedCassandraQuery.getParameterWithIndex(StringBasedCassandraQuery.java:48)
    2. org.springframework.data.cassandra.repository.query.StringBasedCassandraQuery.replacePlaceholders(StringBasedCassandraQuery.java:41)
    3. org.springframework.data.cassandra.repository.query.StringBasedCassandraQuery.createQuery(StringBasedCassandraQuery.java:30)
    4. org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:120)
    4 frames
  5. Spring Data Core
    RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke
    1. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337)
    1 frame
  6. Spring AOP
    JdkDynamicAopProxy.invoke
    1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    2 frames
  7. com.sun.proxy
    $Proxy1486.findByPartitionKey
    1. com.sun.proxy.$Proxy1486.findByPartitionKey(Unknown Source)
    1 frame