CREATE TABLE keyspace.A (
name text,
data list<blob>,
PRIMARY KEY ...
)
List<ByteBuffer> dataList =......
dataList.add(ByteBuffer.wrap(objectArray));
ps.bind().set("name", "aaa", String.class).set("data", dataList, new TypeToken<List<ByteBuffer>>() {} );
It works fine.
However, if we select the table in Cassandra and deserialize the bytebuffer object in the list, the data is corrupted and deserialization is not possible. (parsing error)
TypeToken<List<ByteBuffer>> dataListTypeToken = new TypeToken<List<ByteBuffer>>() {};
rs -> {
List<ByteBuffer> result = new ArrayList<>();
for (Row row : rs) {
List<ByteBuffer> dataList = row.get("data", dataListTypeToken);
result.addAll(dataList);
}
return result;
Do I misunderstand that I deal with Cassandra's list type?