Class CassandraAdminTemplate
java.lang.Object
org.springframework.data.cassandra.core.CassandraTemplate
org.springframework.data.cassandra.core.CassandraAdminTemplate
- All Implemented Interfaces:
Aware
,ApplicationContextAware
,ApplicationEventPublisherAware
,CassandraAdminOperations
,CassandraOperations
,ExecutableDeleteOperation
,ExecutableInsertOperation
,ExecutableSelectOperation
,ExecutableUpdateOperation
,FluentCassandraOperations
Default implementation of
CassandraAdminOperations
.- Author:
- Mark Paluch, Fabio J. Mendes, John Blum, Vagif Zeynalov, Mikhail Polivakha
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.data.cassandra.core.CassandraTemplate
CassandraTemplate.PreparedStatementHandler
Nested classes/interfaces inherited from interface org.springframework.data.cassandra.core.ExecutableDeleteOperation
ExecutableDeleteOperation.DeleteWithQuery, ExecutableDeleteOperation.DeleteWithTable, ExecutableDeleteOperation.ExecutableDelete, ExecutableDeleteOperation.TerminatingDelete
Nested classes/interfaces inherited from interface org.springframework.data.cassandra.core.ExecutableInsertOperation
ExecutableInsertOperation.ExecutableInsert<T>, ExecutableInsertOperation.InsertWithOptions<T>, ExecutableInsertOperation.InsertWithTable<T>, ExecutableInsertOperation.TerminatingInsert<T>
Nested classes/interfaces inherited from interface org.springframework.data.cassandra.core.ExecutableSelectOperation
ExecutableSelectOperation.ExecutableSelect<T>, ExecutableSelectOperation.SelectWithProjection<T>, ExecutableSelectOperation.SelectWithQuery<T>, ExecutableSelectOperation.SelectWithTable<T>, ExecutableSelectOperation.TerminatingSelect<T>
Nested classes/interfaces inherited from interface org.springframework.data.cassandra.core.ExecutableUpdateOperation
ExecutableUpdateOperation.ExecutableUpdate, ExecutableUpdateOperation.TerminatingUpdate, ExecutableUpdateOperation.UpdateWithQuery, ExecutableUpdateOperation.UpdateWithTable
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCassandraAdminTemplate
(com.datastax.oss.driver.api.core.CqlSession session) Constructor used for a basic template configuration.CassandraAdminTemplate
(com.datastax.oss.driver.api.core.CqlSession session, CassandraConverter converter) Constructor used for a basic template configuration.CassandraAdminTemplate
(CqlOperations cqlOperations, CassandraConverter converter) Constructor used for a basic template configuration.CassandraAdminTemplate
(SessionFactory sessionFactory, CassandraConverter converter) Constructor used for a basic template configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
createTable
(boolean ifNotExists, com.datastax.oss.driver.api.core.CqlIdentifier tableName, Class<?> entityClass, Map<String, Object> optionsByName) Create a table with the name given and fields corresponding to the given class.void
dropTable
(boolean ifExists, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Drops thenamed
table.void
dropTable
(com.datastax.oss.driver.api.core.CqlIdentifier tableName) Drops thenamed
table.void
Drops a table based on the givenentity type
.void
dropUserType
(com.datastax.oss.driver.api.core.CqlIdentifier typeName) Drops a user type.com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata
ReturnsKeyspaceMetadata
for the current keyspace.Optional<com.datastax.oss.driver.api.core.metadata.schema.TableMetadata>
getTableMetadata
(com.datastax.oss.driver.api.core.CqlIdentifier keyspace, com.datastax.oss.driver.api.core.CqlIdentifier tableName) LookupTableMetadata
.Methods inherited from class org.springframework.data.cassandra.core.CassandraTemplate
batchOps, count, count, createPreparedStatementHandler, delete, delete, delete, delete, deleteById, execute, exists, exists, getConverter, getCqlOperations, getEntityOperations, getProjectionFactory, getStatementFactory, getTableName, insert, insert, insert, isUsePreparedStatements, maybeCallBeforeConvert, maybeCallBeforeSave, maybeEmitEvent, query, select, select, select, selectOne, selectOne, selectOne, selectOneById, setApplicationContext, setApplicationEventPublisher, setEntityCallbacks, setEntityLifecycleEventsEnabled, setUsePreparedStatements, slice, slice, stream, stream, stream, truncate, update, update, update, update
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.cassandra.core.CassandraAdminOperations
createTable, createTable, getTableMetadata
Methods inherited from interface org.springframework.data.cassandra.core.CassandraOperations
batchOps, batchOps, count, count, delete, delete, delete, delete, deleteById, execute, exists, exists, getConverter, getCqlOperations, getTableName, insert, insert, select, select, select, selectOne, selectOne, selectOne, selectOneById, slice, slice, stream, stream, stream, truncate, update, update, update
Methods inherited from interface org.springframework.data.cassandra.core.ExecutableDeleteOperation
delete
Methods inherited from interface org.springframework.data.cassandra.core.ExecutableInsertOperation
insert
Methods inherited from interface org.springframework.data.cassandra.core.ExecutableSelectOperation
query
Methods inherited from interface org.springframework.data.cassandra.core.ExecutableUpdateOperation
update
-
Field Details
-
DEFAULT_DROP_TABLE_IF_EXISTS
protected static final boolean DEFAULT_DROP_TABLE_IF_EXISTS- See Also:
-
-
Constructor Details
-
CassandraAdminTemplate
public CassandraAdminTemplate(com.datastax.oss.driver.api.core.CqlSession session) Constructor used for a basic template configuration.- Parameters:
session
- must not be null.- Since:
- 2.2
-
CassandraAdminTemplate
public CassandraAdminTemplate(com.datastax.oss.driver.api.core.CqlSession session, CassandraConverter converter) Constructor used for a basic template configuration.- Parameters:
session
- must not be null.converter
- must not be null.
-
CassandraAdminTemplate
Constructor used for a basic template configuration.- Parameters:
sessionFactory
- must not be null.converter
- must not be null.
-
CassandraAdminTemplate
Constructor used for a basic template configuration.- Parameters:
cqlOperations
- must not be null.converter
- must not be null.- Since:
- 2.2
-
-
Method Details
-
getSchemaFactory
- Specified by:
getSchemaFactory
in interfaceCassandraAdminOperations
- Returns:
- the
SchemaFactory
.
-
createTable
public void createTable(boolean ifNotExists, com.datastax.oss.driver.api.core.CqlIdentifier tableName, Class<?> entityClass, Map<String, Object> optionsByName) Description copied from interface:CassandraAdminOperations
Create a table with the name given and fields corresponding to the given class. If the table already exists and parameterifNotExists
is true, this is a no-op and false is returned. If the table doesn't exist, parameterifNotExists
is ignored, the table is created and true is returned.- Specified by:
createTable
in interfaceCassandraAdminOperations
- Parameters:
ifNotExists
- iftrue
, create the table only if it doesn't exist.tableName
- the name of the table.entityClass
- the class whose fields determine the columns created.optionsByName
- table options, given by the string option name and the appropriate option value.
-
dropTable
Description copied from interface:CassandraAdminOperations
Drops a table based on the givenentity type
. The name of the table is derived from either the simple name of theentity class
or name of the table specified with theTable
mapping annotation.- Specified by:
dropTable
in interfaceCassandraAdminOperations
- Parameters:
entityClass
-type
of the entity for which the table will be dropped.
-
dropTable
public void dropTable(com.datastax.oss.driver.api.core.CqlIdentifier tableName) Description copied from interface:CassandraAdminOperations
Drops thenamed
table.- Specified by:
dropTable
in interfaceCassandraAdminOperations
- Parameters:
tableName
-Name
of the table to drop.- See Also:
-
dropTable
public void dropTable(boolean ifExists, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Description copied from interface:CassandraAdminOperations
Drops thenamed
table.- Specified by:
dropTable
in interfaceCassandraAdminOperations
- Parameters:
ifExists
- iftrue
, drop the table only if it exists.tableName
-Name
of the table to drop.
-
dropUserType
public void dropUserType(com.datastax.oss.driver.api.core.CqlIdentifier typeName) Description copied from interface:CassandraAdminOperations
Drops a user type.- Specified by:
dropUserType
in interfaceCassandraAdminOperations
- Parameters:
typeName
- must not be null.
-
getTableMetadata
public Optional<com.datastax.oss.driver.api.core.metadata.schema.TableMetadata> getTableMetadata(com.datastax.oss.driver.api.core.CqlIdentifier keyspace, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Description copied from interface:CassandraAdminOperations
LookupTableMetadata
.- Specified by:
getTableMetadata
in interfaceCassandraAdminOperations
- Parameters:
keyspace
- must not be null.tableName
- must not be null.- Returns:
- the
TableMetadata
or null.
-
getKeyspaceMetadata
public com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata getKeyspaceMetadata()Description copied from interface:CassandraAdminOperations
ReturnsKeyspaceMetadata
for the current keyspace.- Specified by:
getKeyspaceMetadata
in interfaceCassandraAdminOperations
- Returns:
KeyspaceMetadata
for the current keyspace.
-