com.datastax.driver.core.exceptions.InvalidTypeException: Value number is of type varint

Spring JIRA | Peter Cable | 2 years ago
  1. 0

    BigInteger columns map to varint in Cassandra. ColumnReader attempts to read varint columns back as Integers, which throws an exception. I have submitted a pull request with a test for this condition and a fix. Stack trace on failure follows: testQueryWithReference(org.springframework.data.cassandra.test.integration.querymethods.bigintparam.BigIntParamIntegrationTests) Time elapsed: 0.212 sec <<< ERROR! com.datastax.driver.core.exceptions.InvalidTypeException: Value number is of type varint at com.datastax.driver.core.AbstractGettableByIndexData.checkType(AbstractGettableByIndexData.java:73) at com.datastax.driver.core.AbstractGettableByIndexData.getInt(AbstractGettableByIndexData.java:119) at com.datastax.driver.core.AbstractGettableData.getInt(AbstractGettableData.java:24) at org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:71) at org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:38) at org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:30) at org.springframework.data.cassandra.convert.BasicCassandraRowValueProvider.getPropertyValue(BasicCassandraRowValueProvider.java:64) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readPropertyFromRow(MappingCassandraConverter.java:186) at org.springframework.data.cassandra.convert.MappingCassandraConverter$1.doWithPersistentProperty(MappingCassandraConverter.java:150) at org.springframework.data.cassandra.convert.MappingCassandraConverter$1.doWithPersistentProperty(MappingCassandraConverter.java:145) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:309) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readPropertiesFromRow(MappingCassandraConverter.java:145) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readEntityFromRow(MappingCassandraConverter.java:137) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readRow(MappingCassandraConverter.java:114) at org.springframework.data.cassandra.convert.MappingCassandraConverter.read(MappingCassandraConverter.java:202) at org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.getSingleEntity(AbstractCassandraQuery.java:176) at org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:133) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:395) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:373) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy52.findThingByBigInteger(Unknown Source) at org.springframework.data.cassandra.test.integration.querymethods.bigintparam.BigIntParamIntegrationTests.testQueryWithReference(BigIntParamIntegrationTests.java:45)

    Spring JIRA | 2 years ago | Peter Cable
    com.datastax.driver.core.exceptions.InvalidTypeException: Value number is of type varint
  2. 0

    BigInteger columns map to varint in Cassandra. ColumnReader attempts to read varint columns back as Integers, which throws an exception. I have submitted a pull request with a test for this condition and a fix. Stack trace on failure follows: testQueryWithReference(org.springframework.data.cassandra.test.integration.querymethods.bigintparam.BigIntParamIntegrationTests) Time elapsed: 0.212 sec <<< ERROR! com.datastax.driver.core.exceptions.InvalidTypeException: Value number is of type varint at com.datastax.driver.core.AbstractGettableByIndexData.checkType(AbstractGettableByIndexData.java:73) at com.datastax.driver.core.AbstractGettableByIndexData.getInt(AbstractGettableByIndexData.java:119) at com.datastax.driver.core.AbstractGettableData.getInt(AbstractGettableData.java:24) at org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:71) at org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:38) at org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:30) at org.springframework.data.cassandra.convert.BasicCassandraRowValueProvider.getPropertyValue(BasicCassandraRowValueProvider.java:64) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readPropertyFromRow(MappingCassandraConverter.java:186) at org.springframework.data.cassandra.convert.MappingCassandraConverter$1.doWithPersistentProperty(MappingCassandraConverter.java:150) at org.springframework.data.cassandra.convert.MappingCassandraConverter$1.doWithPersistentProperty(MappingCassandraConverter.java:145) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:309) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readPropertiesFromRow(MappingCassandraConverter.java:145) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readEntityFromRow(MappingCassandraConverter.java:137) at org.springframework.data.cassandra.convert.MappingCassandraConverter.readRow(MappingCassandraConverter.java:114) at org.springframework.data.cassandra.convert.MappingCassandraConverter.read(MappingCassandraConverter.java:202) at org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.getSingleEntity(AbstractCassandraQuery.java:176) at org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:133) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:395) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:373) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy52.findThingByBigInteger(Unknown Source) at org.springframework.data.cassandra.test.integration.querymethods.bigintparam.BigIntParamIntegrationTests.testQueryWithReference(BigIntParamIntegrationTests.java:45)

    Spring JIRA | 2 years ago | Peter Cable
    com.datastax.driver.core.exceptions.InvalidTypeException: Value number is of type varint
  3. 0

    DataStax Java Driver -- getDate does not return a timestamp

    Stack Overflow | 1 year ago | Brad Gawne
    com.datastax.driver.core.exceptions.InvalidTypeException: Value accountExpiryDate is of type timestamp
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Can't retrieve by UDT key from cassandra with datastax java driver

    Stack Overflow | 2 years ago | NullProgrammerException
    com.datastax.driver.core.exceptions.InvalidTypeException: Invalid value for CQL type frozen<example_keyspace.my_data_type>, expecting class com.datastax.driver.core.UDTValue but class me.example.Main$MyDataType provided
  6. 0

    Reported on [Stack Overflow|http://stackoverflow.com/questions/31373008/cant-retrieve-by-udt-key-from-cassandra-with-datastax-java-driver] Schema: {code} create keyspace example_keyspace; use example_keyspace; create type my_data_type (value text); create table my_classes (key frozen<my_data_type>, value frozen<my_data_type>, primary key (key)); {code} Java code: {code} package me.example; import com.datastax.driver.core.Cluster; import com.datastax.driver.mapping.Mapper; import com.datastax.driver.mapping.MappingManager; import com.datastax.driver.mapping.annotations.Frozen; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; import com.datastax.driver.mapping.annotations.UDT; public class Main { public static void main(String[] args) { try (Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1") .build()) { Mapper<MyClass> mapper = new MappingManager(cluster.newSession()) .mapper(MyClass.class); MyDataType value = new MyDataType(); value.setValue("theValue"); MyDataType key = new MyDataType(); key.setValue("theKey"); MyClass myClass = new MyClass(); myClass.setKey(key); myClass.setValue(value); mapper.save(myClass); MyClass toret = mapper.get(key); System.out.println(toret.getKey()); System.out.println(toret.getValue().getValue()); } } @Table(keyspace = "example_keyspace", name = "my_classes") public static class MyClass { @PartitionKey @Frozen private MyDataType key; @Frozen private MyDataType value; public MyDataType getKey() { return key; } public void setKey(MyDataType key) { this.key = key; } public MyDataType getValue() { return value; } public void setValue(MyDataType value) { this.value = value; } } @UDT(keyspace = "example_keyspace", name = "my_data_type") public static class MyDataType { private String value; public String getValue() { return value; } public void setValue(String value) { this.value = value; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((value == null) ? 0 : value.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof MyDataType)) { return false; } MyDataType other = (MyDataType) obj; if (value == null) { if (other.value != null) { return false; } } else if (!value.equals(other.value)) { return false; } return true; } } } {code} It fails with this exception: {code} Exception in thread "main" com.datastax.driver.core.exceptions.InvalidTypeException: Invalid value for CQL type frozen<example_keyspace.my_data_type>, expecting class com.datastax.driver.core.UDTValue but class me.example.Main$MyDataType provided at com.datastax.driver.core.DataType.serialize(DataType.java:619) at com.datastax.driver.mapping.Mapper.getQuery(Mapper.java:320) at com.datastax.driver.mapping.Mapper.get(Mapper.java:342) at me.example.Main.main(Main.java:31) {code} There is a workaround: {code} MappingManager manager = new MappingManager(cluster.newSession()); UDTMapper<MyDataType> myDataTypeMapper = manager.udtMapper(MyDataType.class); UDTValue keyAsUDTValue = myDataTypeMapper.toUDT(key); MyClass toret = mapper.get(keyAsUDTValue); {code}

    DataStax JIRA | 2 years ago | Olivier Michallat
    com.datastax.driver.core.exceptions.InvalidTypeException: Invalid value for CQL type frozen<example_keyspace.my_data_type>, expecting class com.datastax.driver.core.UDTValue but class me.example.Main$MyDataType provided

    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.InvalidTypeException

      Value number is of type varint

      at com.datastax.driver.core.AbstractGettableByIndexData.checkType()
    2. DataStax Java Driver for Apache Cassandra - Core
      AbstractGettableData.getInt
      1. com.datastax.driver.core.AbstractGettableByIndexData.checkType(AbstractGettableByIndexData.java:73)
      2. com.datastax.driver.core.AbstractGettableByIndexData.getInt(AbstractGettableByIndexData.java:119)
      3. com.datastax.driver.core.AbstractGettableData.getInt(AbstractGettableData.java:24)
      3 frames
    3. Spring Data Cassandra - Core
      MappingCassandraConverter$1.doWithPersistentProperty
      1. org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:71)
      2. org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:38)
      3. org.springframework.data.cassandra.convert.ColumnReader.get(ColumnReader.java:30)
      4. org.springframework.data.cassandra.convert.BasicCassandraRowValueProvider.getPropertyValue(BasicCassandraRowValueProvider.java:64)
      5. org.springframework.data.cassandra.convert.MappingCassandraConverter.readPropertyFromRow(MappingCassandraConverter.java:186)
      6. org.springframework.data.cassandra.convert.MappingCassandraConverter$1.doWithPersistentProperty(MappingCassandraConverter.java:150)
      7. org.springframework.data.cassandra.convert.MappingCassandraConverter$1.doWithPersistentProperty(MappingCassandraConverter.java:145)
      7 frames
    4. Spring Data Core
      BasicPersistentEntity.doWithProperties
      1. org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:309)
      1 frame
    5. Spring Data Cassandra - Core
      AbstractCassandraQuery.execute
      1. org.springframework.data.cassandra.convert.MappingCassandraConverter.readPropertiesFromRow(MappingCassandraConverter.java:145)
      2. org.springframework.data.cassandra.convert.MappingCassandraConverter.readEntityFromRow(MappingCassandraConverter.java:137)
      3. org.springframework.data.cassandra.convert.MappingCassandraConverter.readRow(MappingCassandraConverter.java:114)
      4. org.springframework.data.cassandra.convert.MappingCassandraConverter.read(MappingCassandraConverter.java:202)
      5. org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.getSingleEntity(AbstractCassandraQuery.java:176)
      6. org.springframework.data.cassandra.repository.query.AbstractCassandraQuery.execute(AbstractCassandraQuery.java:133)
      6 frames
    6. Spring Data Core
      RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke
      1. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:395)
      2. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:373)
      2 frames
    7. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
      2 frames
    8. com.sun.proxy
      $Proxy52.findThingByBigInteger
      1. com.sun.proxy.$Proxy52.findThingByBigInteger(Unknown Source)
      1 frame
    9. org.springframework.data
      BigIntParamIntegrationTests.testQueryWithReference
      1. org.springframework.data.cassandra.test.integration.querymethods.bigintparam.BigIntParamIntegrationTests.testQueryWithReference(BigIntParamIntegrationTests.java:45)
      1 frame