1
votes

I have a Java class that is using the datastax cassandra driver to write a pojo to a cassandra table. Everything works fine, until it comes to having to write a class object to the cassandra table. It throws this error:

Caused by: com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [frozen< projKeySpace.smi > <-> code.generic.common.data.MyCustomSmiObject]

So I have tried a lot of different things to try and make the attribute "Frozen", but nothing works and I keep getting the same error. Here is an example of the class object.

@Table(keyspace="projkeyspace", name="summarytable")
public class DataGroupingObject implements Serializable {

    @Column(name = "objid")
    private String objId;
    @Column(name = "timeofjob")
    private Date timeOfJob;

    @Column(name = "smiobjectinput")
    @Frozen
    //Have also tried:
    //@Frozen("frozen<projKeySpace.smi>")
    //@Frozen("frozen<smi>")
    //@Frozen("frozen<MyCustomSmiObject>")
    //And all other permutations I can think of...
    private MyCustomSmiObject myCustomSmiObject; //The problem attribute

    @Column(name = "column5")
    private String dataForColumn5;

    //Getters and setters....
}

So what am I overlooking? Digging into the datastax documentation didn't show much beyond this, http://docs.datastax.com/en/drivers/java/2.2/com/datastax/driver/mapping/annotations/Frozen.html , which I tried.

I also have tried having the MyCustomSmiObject be mapped to the frozen 'projkeyspace.smi' and that didn't work (of course I didn't think it would since there isn't actually a table in cassandra called smi, its just a type) but here is an example of it:

@Table(keyspace="projkeyspace", name="smi")
public class MyCustomSmiObject implements Serializable {

    @Column(name = "idstring")
    private String idString;
    @Column(name = "valuenum")
    private Double valueNum;

    //Getters and Setters....
}

So like I said, I am at a loss. Any help would be greatly appreciated and thanks in advance!

1

1 Answers

1
votes

smi is a UDT isn't it? In that case MyCustomSmiObject should be annotated with @UDT(keyspace="projkeyspace", name="smi") instead of @Table. By doing that, the driver should detect that this is a UDT and it will register a custom codec for it which will allow it to be able to properly serialize and deserialize it.

On another note the @Frozen annotation currently has no impact on the mapper, it is only informational at this time until the mapper has support for schema generation.