public class SessionFactoryFactoryBean extends AbstractFactoryBean<SessionFactory>
SessionFactory with support for executing CQL and initializing
the database schema (a.k.a. keyspace). This factory bean invokes a SessionFactoryInitializer to prepare a
keyspace before applying schema actions such as creating user-defined types and tables.SessionFactoryInitializer| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
DEFAULT_CREATE_IF_NOT_EXISTS |
protected static boolean |
DEFAULT_DROP_TABLES |
protected static boolean |
DEFAULT_DROP_UNUSED_TABLES |
loggerOBJECT_TYPE_ATTRIBUTE| Constructor and Description |
|---|
SessionFactoryFactoryBean() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected SessionFactory |
createInstance() |
protected void |
createTables(boolean drop,
boolean dropUnused,
boolean ifNotExists)
Perform schema actions.
|
void |
destroy() |
Class<?> |
getObjectType() |
protected void |
performSchemaAction()
Perform the configure
SchemaAction using CassandraMappingContext metadata. |
void |
setConverter(CassandraConverter converter)
Set the
CassandraConverter to use. |
void |
setKeyspaceCleaner(KeyspacePopulator keyspaceCleaner)
Set the
KeyspacePopulator to execute during the bean destruction phase, cleaning up the keyspace and
leaving it in a known state for others. |
void |
setKeyspacePopulator(KeyspacePopulator keyspacePopulator)
Set the
KeyspacePopulator to execute during the bean initialization phase. |
void |
setSchemaAction(SchemaAction schemaAction)
Set the
SchemaAction. |
void |
setSession(com.datastax.oss.driver.api.core.CqlSession session)
Set the
CqlSession to use. |
destroyInstance, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingletonprotected static final boolean DEFAULT_CREATE_IF_NOT_EXISTS
protected static final boolean DEFAULT_DROP_TABLES
protected static final boolean DEFAULT_DROP_UNUSED_TABLES
public void setConverter(CassandraConverter converter)
CassandraConverter to use. Schema actions will derive table and user type information from the
CassandraMappingContext inside converter.converter - must not be null.public void setKeyspaceCleaner(@Nullable KeyspacePopulator keyspaceCleaner)
KeyspacePopulator to execute during the bean destruction phase, cleaning up the keyspace and
leaving it in a known state for others.keyspaceCleaner - the KeyspacePopulator to use during cleanup.setKeyspacePopulator(org.springframework.data.cassandra.core.cql.session.init.KeyspacePopulator)public void setKeyspacePopulator(@Nullable KeyspacePopulator keyspacePopulator)
KeyspacePopulator to execute during the bean initialization phase. The
KeyspacePopulator is invoked before creating
the schema.keyspacePopulator - the KeyspacePopulator to use during initialization.setKeyspaceCleaner(org.springframework.data.cassandra.core.cql.session.init.KeyspacePopulator)public void setSchemaAction(SchemaAction schemaAction)
SchemaAction.schemaAction - must not be null.public void setSession(com.datastax.oss.driver.api.core.CqlSession session)
CqlSession to use.session - must not be null.public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface InitializingBeanafterPropertiesSet in class AbstractFactoryBean<SessionFactory>Exceptionprotected SessionFactory createInstance()
createInstance in class AbstractFactoryBean<SessionFactory>public void destroy()
throws Exception
destroy in interface DisposableBeandestroy in class AbstractFactoryBean<SessionFactory>Exception@Nullable public Class<?> getObjectType()
getObjectType in interface FactoryBean<SessionFactory>getObjectType in class AbstractFactoryBean<SessionFactory>protected void performSchemaAction()
throws Exception
SchemaAction using CassandraMappingContext metadata.Exceptionprotected void createTables(boolean drop,
boolean dropUnused,
boolean ifNotExists)
throws Exception
drop - true to drop types/tables.dropUnused - true to drop unused types/tables (i.e. types/tables not know to be used by
CassandraMappingContext).ifNotExists - true to perform creations fail-safe by adding IF NOT EXISTS to each creation
statement.ExceptionCopyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.