com.datastax.driver.core.exceptions.InvalidQueryException: Invalid amount of bind variables

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
    com.datastax.driver.core.exceptions.InvalidQueryException: Invalid amount of bind variables
  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
    com.datastax.driver.core.exceptions.InvalidQueryException: Invalid amount of bind variables
  3. 0

    GitHub comment 12#37273045

    GitHub | 3 years ago | pyr
    com.datastax.driver.core.exceptions.InvalidQueryException: LIMIT must be strictly positive
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    how to insert timeuuid into cassandra using datastax java driver OR Invalid version for TimeUUID

    Stack Overflow | 3 years ago | user2681607
    com.datastax.driver.core.exceptions.InvalidQueryException: Invalid version for TimeUUID type.
  6. 0

    PRIMARY KEY part colname cannot be restricted by IN relation

    Stack Overflow | 3 years ago | Easility
    com.datastax.driver.core.exceptions.InvalidQueryException: PRIMARY KEY part colname cannot be restricted by IN relation

    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. com.datastax.driver.core.exceptions.InvalidQueryException

      Invalid amount of bind variables

      at com.datastax.driver.core.exceptions.InvalidQueryException.copy()
    2. DataStax Java Driver for Apache Cassandra - Core
      Session.execute
      1. com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:35)
      2. com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException(ResultSetFuture.java:269)
      3. com.datastax.driver.core.ResultSetFuture.getUninterruptibly(ResultSetFuture.java:183)
      4. com.datastax.driver.core.Session.execute(Session.java:111)
      4 frames
    3. Spring CQL
      CqlTemplate.query
      1. org.springframework.cassandra.core.CqlTemplate$12.doInSession(CqlTemplate.java:519)
      2. org.springframework.cassandra.core.CqlTemplate$12.doInSession(CqlTemplate.java:510)
      3. org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:487)
      4. org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:510)
      5. org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:499)
      6. org.springframework.cassandra.core.CqlTemplate.query(CqlTemplate.java:409)
      7. org.springframework.cassandra.core.CqlTemplate.query(CqlTemplate.java:436)
      8. org.springframework.cassandra.core.CqlTemplate.query(CqlTemplate.java:430)
      8 frames
    4. Spring Data Cassandra - Core
      AbstractCassandraQuery.execute
      1. org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:122)
      1 frame
    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
      $Proxy1408.findByPartitionKey
      1. com.sun.proxy.$Proxy1408.findByPartitionKey(Unknown Source)
      1 frame