What, where and how should I register something as a codec for a custom type
determined the type
@UDT(name = "bucket", keyspace = "us") public class BucketType { @Field(name = "event_time") private Date eventTime; @Field(name = "product_id") private String productId; //setters and getters } table structure
CREATE TABLE keyspace.shops ( user_id stext, buckets list<frozen <bucket>> PRIMARY KEY (user_id)); Dependencies
compile group: 'com.datastax.cassandra', name: 'cassandra-driver-mapping', version: '3.5.0' compile group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.5.0' I make a request to cassandra
Session session = cluster.connect(); ResultSet resultSet = session.execute("select * from keyspace.shops;"); resultSet.forEach(row -> { List<BucketType> list1 = row.getList(1, BucketType.class); } Tried different methods get, getValue, and indices different. It gives an error.
com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [ups.cart_add <-> com.test.entity.type.BucketType] at com.datastax.driver.core.CodecRegistry.notFound(CodecRegistry.java:741) ~[cassandra-driver-core-3.5.0.jar:na] at com.datastax.driver.core.CodecRegistry.createCodec(CodecRegistry.java:588) ~[cassandra-driver-core-3.5.0.jar:na] at com.datastax.driver.core.CodecRegistry.findCodec(CodecRegistry.java:558) ~[cassandra-driver-core-3.5.0.jar:na]
row.getList("buckets", BucketType.class)- Senior Pomidorrow.getList("buckets", TypeToken.of(BucketType.class))- Senior Pomidorcluster.connect("ups"). - Senior Pomidor