0
votes

Im asking for the possibility to create a table in cassandra that contains a List of Map! like that:

CREATE TABLE IF NOT EXISTS agence(
id timeuuid,
code text,
libelle text,   
adresse set<frozen<map<text,text>>>,
conseillers  set<frozen<map<text,text>>>,
compagnie_id timeuuid,

...

In spring Data I have this query:

findAll()

then I got this error:

Query; CQL [SELECT * FROM agence;]; Codec not found for requested operation: [map<varchar, varchar> <-> java.util.Map]

I dont know if there is a bad configuration or bad use of cassandra!!

Anyone has suggestion please?

1
Why you don't use Object Mapper from DataStax driver? And findAll is really anti-patern for Cassandra. You should access data by key...Alex Ott
the findAll is just to test the request... however access data by key?ATEF CHAREF
you need to have at least partition key in the where condition, or part or full primary key...Alex Ott

1 Answers

0
votes

Finally I get a solution:

    /** The conseillers. */
@Column(value = "conseillers")
@Frozen
@FrozenKey
@FrozenValue
private Set<Map<String, String>> conseillers;

Like this we can map map <-> java.util.Map

    for(Row row : cassandraOperations.select("SELECT conseillers FROM agence", Row.class)){
        Set<Map<String, String>> info = mapperCassandra(row, "conseillers");
    }
}

private Set<Map<String, String>> mapperCassandra(Row row, String type) {
    return  row.getSet(type,    TypeTokens.mapOf(TypeToken.of(String.class), TypeToken.of(String
            .class)));

}