com.datastax.driver.core.exceptions.InvalidTypeException: Invalid type for value 0, column type is counter but class java.lang.Integer provided

DataStax JIRA | mkjellman | 4 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    When inserting a java.lang.Number into Cassandra, the Datastax driver effectively expects an exact match on the class. This means that callers are expected to pre-coerce their inputs, which is surprising and fragile. (Some libraries, such as Jackson, are fond of producing different Number types depending on the magnitude of the data.) This issue was encountered while using the Cassaforte library from Clojurewerkz (which uses the datastax lib v1.0.3) The stack trace is below: {noformat} com.datastax.driver.core.exceptions.InvalidTypeException: Invalid type for value 3 of CQL type bigint, expecting class java.lang.Long but class java.lang.Integer provided at com.datastax.driver.core.BoundStatement.bind(BoundStatement.java:190) ~[cassandra-driver-core-1.0.3.jar:na] at com.datastax.driver.core.PreparedStatement.bind(PreparedStatement.java:158) ~[cassandra-driver-core-1.0.3.jar:na] at clojurewerkz.cassaforte.client$build_statement.invoke(client.clj:170) ~[classes/:na] at clojurewerkz.cassaforte.client$execute.doInvoke(client.clj:291) ~[classes/:na] at clojure.lang.RestFn.invoke(RestFn.java:457) ~[clojure-1.4.0.jar:na] at clojurewerkz.cassaforte.multi.cql$execute_.invoke(cql.clj:17) ~[classes/:na] at clojurewerkz.cassaforte.multi.cql$insert.doInvoke(cql.clj:132) ~[classes/:na] ... {noformat}

    DataStax JIRA | 3 years ago | Tim McCormack
    com.datastax.driver.core.exceptions.InvalidTypeException: Invalid type for value 3 of CQL type bigint, expecting class java.lang.Long but class java.lang.Integer provided
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    When inserting a java.lang.Number into Cassandra, the Datastax driver effectively expects an exact match on the class. This means that callers are expected to pre-coerce their inputs, which is surprising and fragile. (Some libraries, such as Jackson, are fond of producing different Number types depending on the magnitude of the data.) This issue was encountered while using the Cassaforte library from Clojurewerkz (which uses the datastax lib v1.0.3) The stack trace is below: {noformat} com.datastax.driver.core.exceptions.InvalidTypeException: Invalid type for value 3 of CQL type bigint, expecting class java.lang.Long but class java.lang.Integer provided at com.datastax.driver.core.BoundStatement.bind(BoundStatement.java:190) ~[cassandra-driver-core-1.0.3.jar:na] at com.datastax.driver.core.PreparedStatement.bind(PreparedStatement.java:158) ~[cassandra-driver-core-1.0.3.jar:na] at clojurewerkz.cassaforte.client$build_statement.invoke(client.clj:170) ~[classes/:na] at clojurewerkz.cassaforte.client$execute.doInvoke(client.clj:291) ~[classes/:na] at clojure.lang.RestFn.invoke(RestFn.java:457) ~[clojure-1.4.0.jar:na] at clojurewerkz.cassaforte.multi.cql$execute_.invoke(cql.clj:17) ~[classes/:na] at clojurewerkz.cassaforte.multi.cql$insert.doInvoke(cql.clj:132) ~[classes/:na] ... {noformat}

    DataStax JIRA | 3 years ago | Tim McCormack
    com.datastax.driver.core.exceptions.InvalidTypeException: Invalid type for value 3 of CQL type bigint, expecting class java.lang.Long but class java.lang.Integer provided

    Root Cause Analysis

    1. com.datastax.driver.core.exceptions.InvalidTypeException

      Invalid type for value 0, column type is counter but class java.lang.Integer provided

      at com.datastax.driver.core.BoundStatement.bind()
    2. DataStax Java Driver for Apache Cassandra - Core
      PreparedStatement.bind
      1. com.datastax.driver.core.BoundStatement.bind(BoundStatement.java:168)
      2. com.datastax.driver.core.PreparedStatement.bind(PreparedStatement.java:128)
      2 frames