use of com.datastax.driver.core.UserType in project jnosql-diana-driver by eclipse.
the class CassandraConverter method getUDT.
private static UDT getUDT(String name, UDTValue udtValue) {
List<Column> columns = new ArrayList<>();
UserType type = udtValue.getType();
for (String fieldName : type.getFieldNames()) {
DataType fieldType = type.getFieldType(fieldName);
Object elementValue = udtValue.get(fieldName, CODE_REGISTRY.codecFor(fieldType));
if (elementValue != null) {
columns.add(Column.of(fieldName, elementValue));
}
}
return UDT.builder(type.getTypeName()).withName(name).addUDT(columns).build();
}
use of com.datastax.driver.core.UserType in project jnosql-diana-driver by eclipse.
the class QueryUtils method insertUDT.
private static void insertUDT(UDT udt, String keyspace, Session session, Insert insert) {
UserType userType = session.getCluster().getMetadata().getKeyspace(keyspace).getUserType(udt.getUserType());
Iterable elements = Iterable.class.cast(udt.get());
Object udtValue = getUdtValue(userType, elements);
insert.value(getName(udt), udtValue);
}
Aggregations