}
private void createTable(Session session, EntityMeta entityMeta) {
String qualifiedTableName = entityMeta.config().getQualifiedTableName();
final List<String> indexes = new LinkedList<>();
final Create createTable = SchemaBuilder.createTable(qualifiedTableName);
for (PropertyMeta pm : entityMeta.getAllMetasExceptIdAndCounters()) {
String cql3ColumnName = pm.getCQL3ColumnName();
Class<?> valueClass = pm.config().getCQL3ValueType();
final boolean staticColumn = pm.structure().isStaticColumn();
switch (pm.type()) {
case SIMPLE:
createTable.addColumn(cql3ColumnName, toCQLDataType(valueClass), staticColumn);
if (pm.structure().isIndexed()) {
indexes.add(pm.forTableCreation().createNewIndexScript(entityMeta.config().getTableName()));
}
break;
case LIST:
createTable.addColumn(cql3ColumnName, DataType.list(toCQLDataType(valueClass)), staticColumn);
break;
case SET:
createTable.addColumn(cql3ColumnName, DataType.set(toCQLDataType(valueClass)), staticColumn);
break;
case MAP:
Class<?> keyClass = pm.config().getCQL3KeyType();
createTable.addColumn(cql3ColumnName, DataType.map(toCQLDataType(keyClass), toCQLDataType(valueClass)), staticColumn);
break;
default:
break;
}
}
final PropertyMeta idMeta = entityMeta.getIdMeta();
buildPrimaryKey(idMeta, createTable);
final Create.Options tableOptions = createTable.withOptions();
idMeta.forTableCreation().addClusteringOrder(tableOptions);
final String tableComment = entityMeta.config().getTableComment();
if (StringUtils.isNotBlank(tableComment)) {
tableOptions.comment(tableComment);
}