spring-data-cassandra, Cassandra storing List<Integer> as field

Max

I have problem storing field of List as field of my table in cassandra database.

I'm using spring-data-cassandra, version 1.4.1.RELEASE.

My model contains:

@Column
@CassandraType(type = DataType.Name.LIST)
private List<Integer> somedata;

I would like to auto create my db tables with SchemaAction.RECREATE_DROP_UNUSED Schema action in my config class:

@Override
public SchemaAction getSchemaAction() {
    return SchemaAction.RECREATE_DROP_UNUSED;
}

It tries to create table, but following exception occurs:

Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: expected 1 of typed arguments for the property  'somedata' type is 'interface java.util.List' in the entity <my class here>
Max

Ok, found solution after digging into spring-data-cassandra source:

@CassandraType(type = DataType.Name.LIST, typeArguments = { DataType.Name.FLOAT } )
private List<Float> position;

You need to add typeArguments, to specify DataType of generic type. Exception mentioned in question is thrown when invalid number of those typeArguments is passed. In my case there was 0 and 1 is required.

@Column annotation proved to be not required here.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Mapping cassandra list<frozen<list<int>>> field to Java in spring-data-cassandra

How to ignore an entity field in Spring Data Cassandra?

Understanding internal data storing by cassandra

Storing schema less data in cassandra

Spring Data Cassandra and PreparedStatementCache

Storing Data in Cassandra and Visualizing it in ThingsBoard Dashboard

Spring Boot Data Embedded Cassandra

Spring data Cassandra, Allow filtering

Spring Data Cassandra LocalDateTime Conversion

Annotation for UDT by Spring data Cassandra

Spring Data Cassandra Counter update

Spring Data Cassandra and Map of Maps

cassandra is storing 'z' (which is a wrong date format in my case )in the field

NodeJS + Cassandra: Unable to retrieve boolean and integer data

How to use Testcontainers Cassandra with Spring Data for Apache Cassandra?

Cassandra vs MongoDB - Storing JSON data with previously unknown keys?

Spring Cassandra store a List with custom object's

Create Spring.Data.Cassandra keyspace in runtime

spring cassandra data Version 2.1.4 pagination

Spring Data Cassandra: "No property findAll for type User"

spring-data-cassandra CassandraBatchTemplate is not public

How to create custom conversions for Spring Data Cassandra?

How to set Spring Data Cassandra keyspace dynamically?

spring boot data cassandra reactive JmxReporter problem

spring data cassandra reactive - custom delete method

spring-data-cassandra set consistency level

User Defined Type with spring-data-cassandra

How to use insert asynchronously into Cassandra with Spring Data?

spring-cassandra UDT data insert