vendredi 23 septembre 2016

Cannot get class of a Map

getMap(String name, Class<K> keysClass, Class<V> valuesClass)

Parameters:
name - the name of the column to retrieve.
keysClass - the class for the keys of the map to retrieve.
valuesClass - the class for the values of the map to retrieve.

I am using above method from DataStax java driver for cassandra for reading a column(say, column name is media) of map type.

If type of that column were Map<int, varchar>, I could call getMap() method as follow:

getMap("media", Integer.class, String.class)

However the type of that column is:

 Map<int, Map<int, varchar>>

My question is how can I pass the third argument in getMap() method?

So far I have tried this:

row.getMap("media", Long.class, Map.class);

But got below exception:

com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [map<int, varchar> <-> java.util.Map]

As from the exception, I can get that it is expecting class type Map<Integer, String> as it's third argument.

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire