0

In spring-data-cassandra, how can I use an Enum inside a Map in one of my entities. E.g.

public class User implements Serializable {
  private Map<String, LanguageLevel> languageToLevelMap;

  // getters and setters omitted
}

Here, LanguageLevel is an Enum.

public enum LanguageLevel {
  GOOD,
  BAD
}

The result is

com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [ANY <-> de.test.LanguageLevel]
spaceQchen
  • 11
  • 3

1 Answers1

0

first create enums like this

public enum LangEnums { LANGUAGELEVEL}

and then create HasMap Like This

Map <String, Enum>  mapWithEnums=new HashMap<>()
mapWithEnums.put("Test", LANGUAGELEVEL)
Zak
  • 101
  • 3
  • Hi Zak, thanks for the comment. However, thats more or less what I do and what leads to the above exception, the moment i try to store the entity in Cassandra. – spaceQchen Nov 21 '17 at 15:41
  • This might help https://stackoverflow.com/questions/37588733/datastax-cassandra-driver-throwing-codecnotfoundexception – Zak Nov 21 '17 at 15:50