-1

we used dse-driver 1.8.2 in our code, i have entity defined as:

public class HistoryByEmail implements Serializable {
  ...
  @Column(name = ADDITIONAL_DATA)
  private Map<String, String> additionalData;
}

when i tried to read the value out of that column i got this error:

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

the I added codec at that column:

  @Column(name = ADDITIONAL_DATA, codec = TypeCodec.MapCodec.class)
  private Map<String, String> additionalData;

but the code won't get compiled, also tried the following approach, none of them works:

  @Column(name = ADDITIONAL_DATA, codec = TypeCodec.AbstractMapCodec<String, String>.class)
  private Map<String, String> additionalData;

  @Column(name = ADDITIONAL_DATA, codec = TypeCodec.AbstractMapCodec<>.class)
  private Map<String, String> additionalData;
Alex Ott
  • 80,552
  • 8
  • 87
  • 132
user468587
  • 4,799
  • 24
  • 67
  • 124

1 Answers1

0

From the error it looks like that the corresponding column has type text, not the map<text, text> - either change definition of the table, or adjust the variable type.

Maybe you have JSON string there instead of real Cassandra map? In this case you can use one of the existing JSON codecs.

Alex Ott
  • 80,552
  • 8
  • 87
  • 132