public abstract class AbstractCreateStatement<T extends AbstractCreateStatement<T>> extends SchemaStatement
Modifier and Type | Field and Description |
---|---|
protected boolean |
ifNotExists |
protected com.google.common.base.Optional<String> |
keyspaceName |
protected Map<String,com.datastax.driver.core.schemabuilder.ColumnType> |
simpleColumns |
idempotent, NULL_PAYLOAD_VALUE
Constructor and Description |
---|
AbstractCreateStatement() |
Modifier and Type | Method and Description |
---|---|
T |
addColumn(String columnName,
DataType dataType)
Add a column definition to this CREATE statement.
|
T |
addUDTColumn(String columnName,
UDTType udtType)
Add a column definition to this CREATE statement, when the type contains a UDT.
|
T |
addUDTListColumn(String columnName,
UDTType udtType)
Shorthand to add a column definition to this CREATE statement, when the type is a list of UDT.
|
T |
addUDTMapColumn(String columnName,
DataType keyType,
UDTType valueUdtType)
Shorthand to add a column definition to this CREATE statement, when the type is a map with a UDT value type.
|
T |
addUDTMapColumn(String columnName,
UDTType udtKeyType,
DataType valueType)
Shorthand to add a column definition to this CREATE statement, when the type is a map with a UDT key type.
|
T |
addUDTMapColumn(String columnName,
UDTType udtKeyType,
UDTType udtValueType)
Shorthand to add a column definition to this CREATE statement, when the type is a map with UDT key and value types.
|
T |
addUDTSetColumn(String columnName,
UDTType udtType)
Shorthand to add a column definition to this CREATE statement, when the type is a set of UDT.
|
protected String |
buildColumnType(Map.Entry<String,com.datastax.driver.core.schemabuilder.ColumnType> entry) |
T |
ifNotExists()
Add the 'IF NOT EXISTS' condition to this CREATE statement.
|
getKeyspace, getNamedValues, getQueryString, getRoutingKey, getValues, hasValues, usesNamedValues
getQueryString, hasValues, toString
disableTracing, enableTracing, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getOutgoingPayload, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, isIdempotent, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setIdempotent, setOutgoingPayload, setPagingState, setPagingState, setPagingStateUnsafe, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevel
protected com.google.common.base.Optional<String> keyspaceName
protected boolean ifNotExists
protected Map<String,com.datastax.driver.core.schemabuilder.ColumnType> simpleColumns
public T ifNotExists()
public T addColumn(String columnName, DataType dataType)
addColumn("myList",DataType.list(DataType.text()))
To add a set column:
addColumn("mySet",DataType.set(DataType.text()))
To add a map column:
addColumn("myMap",DataType.map(DataType.cint(),DataType.text()))
columnName
- the name of the column to be added.dataType
- the data type of the column to be added.public T addUDTColumn(String columnName, UDTType udtType)
columnName
- the name of the column to be added.udtType
- the UDT type of the column to be added. Use SchemaBuilder.frozen(String)
or SchemaBuilder.udtLiteral(String)
.public T addUDTListColumn(String columnName, UDTType udtType)
columnName
- the name of the column to be addedudtType
- the udt type of the column to be added. Use SchemaBuilder.frozen(String)
.public T addUDTSetColumn(String columnName, UDTType udtType)
columnName
- the name of the column to be addedudtType
- the udt type of the column to be added. Use SchemaBuilder.frozen(String)
.public T addUDTMapColumn(String columnName, DataType keyType, UDTType valueUdtType)
addUDTMapColumn("addresses", DataType.text(), frozen("address"));
columnName
- the name of the column to be added.keyType
- the key type of the column to be added.valueUdtType
- the value UDT type of the column to be added. Use SchemaBuilder.frozen(String)
.public T addUDTMapColumn(String columnName, UDTType udtKeyType, DataType valueType)
addUDTMapColumn("roles", frozen("user"), DataType.text());
columnName
- the name of the column to be added.udtKeyType
- the key UDT type of the column to be added. Use SchemaBuilder.frozen(String)
.valueType
- the value raw type of the column to be added.public T addUDTMapColumn(String columnName, UDTType udtKeyType, UDTType udtValueType)
addUDTMapColumn("users", frozen("user"), frozen("address"));
columnName
- the name of the column to be added.udtKeyType
- the key UDT type of the column to be added. Use SchemaBuilder.frozen(String)
.udtValueType
- the value UDT type of the column to be added. Use SchemaBuilder.frozen(String)
.protected String buildColumnType(Map.Entry<String,com.datastax.driver.core.schemabuilder.ColumnType> entry)