Reputation: 903
I am trying to use Datastax's UDT mapper for a table which contains the list of UDT's. The driver throws an exception while trying to instantiate the UDTmapper. It seems to be unable to map the list of instances of the class which represents my UDT.
The user defined types and tables are created with the statements:
CREATE TYPE IF NOT EXISTS keyspace.value (
id uuid,
values list<text>
);
CREATE TYPE IF NOT EXISTS keyspace.epoch (
name text,
description text,
start_time timestamp,
duration int,
values list<frozen<value>>
);
CREATE TABLE IF NOT EXISTS keyspace.service_level_agreements (
id uuid,
name text,
description text,
epochs list<frozen<epoch>>,
chargeback_info uuid,
PRIMARY KEY (id)
);
The classes are:
public class Value {
@Field(name = "id")
private UUID sloId;
@Field(name = "values")
private List<String> values;
}
public class Epoch {
@Field(name = "name")
private String name;
@Field(name = "description")
private String description;
@Field(name = "start_time")
private Date startTime;
@Field(name = "duration")
private long duration;
@Field(name = "values")
private List<Value> values;
}
@UDT (keyspace = "keyspace", name = "service_level_agreements")
public class ServiceLevelAgreement e {
@Field(name = "id")
private UUID id;
@Field(name = "name")
private String name;
@Field(name = "description")
private String description;
@Field(name = "epochs")
private List<Epoch> epochs;
@Field(name = "chargeback_info")
private UUID charegebackInfo;
}
When I am trying to instantiate UDT mapper I am getting an exception:
Cannot map unknown class com.me.Epoch for field private java.util.List com.me.ServiceLevelAgreement.epochs
It seems that the UDT mapper cannot fund Epoch class although it is on the classpath. I also tried to move Epoch class inside ServiceLevelAgreement , but it did not help. Any Idea what I am doing wrong?
Upvotes: 0
Views: 817
Reputation: 903
The issue was caused by my misunderstanding what class should be tagged with @UDT annotation. I put it instead of the table annotation, but it should in the class which describes my UDT. After I fixedthe annotations, everything started working.
Upvotes: 1