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