open class EmbeddedDatabaseFactory
Factory for creating an EmbeddedDatabase instance.
Callers are guaranteed that the returned database has been fully initialized and populated.
The factory can be configured as follows:
#generateUniqueDatabaseName to set a unique, random name for the database. #setDatabaseName to set an explicit name for the database. #setDatabaseType to set the database type if you wish to use one of the supported types. #setDatabaseConfigurer to configure support for a custom embedded database type. #setDatabasePopulator to change the algorithm used to populate the database. #setDataSourceFactory to change the type of DataSource used to connect to the database. After configuring the factory, call #getDatabase() to obtain a reference to the EmbeddedDatabase instance.
Author
Keith Donald
Author
Juergen Hoeller
Author
Sam Brannen
Since
3.0
EmbeddedDatabaseFactory()
Factory for creating an EmbeddedDatabase instance. Callers are guaranteed that the returned database has been fully initialized and populated. The factory can be configured as follows:
After configuring the factory, call |
static val DEFAULT_DATABASE_NAME: String
Default name for an embedded database: {@value} |
open fun getDatabase(): EmbeddedDatabase
Factory method that returns the EmbeddedDatabase instance, which is also a DataSource. |
|
open fun setDataSourceFactory(dataSourceFactory: DataSourceFactory): Unit
Set the factory to use to create the DataSource instance that connects to the embedded database. Defaults to SimpleDriverDataSourceFactory. |
|
open fun setDatabaseConfigurer(configurer: EmbeddedDatabaseConfigurer): Unit
Set the strategy that will be used to configure the embedded database instance. Call this when you wish to use an embedded database type not already supported. |
|
open fun setDatabaseName(databaseName: String): Unit
Set the name of the database. Defaults to {@value #DEFAULT_DATABASE_NAME}. Will be overridden if the |
|
open fun setDatabasePopulator(populator: DatabasePopulator): Unit
Set the strategy that will be used to initialize or populate the embedded database. Defaults to |
|
open fun setDatabaseType(type: EmbeddedDatabaseType): Unit
Set the type of embedded database to use. Call this when you wish to configure one of the pre-supported types. Defaults to HSQL. |
|
open fun setGenerateUniqueDatabaseName(generateUniqueDatabaseName: Boolean): Unit
Set the Setting this flag to |
open class EmbeddedDatabaseFactoryBean : EmbeddedDatabaseFactory, FactoryBean<DataSource>, InitializingBean, DisposableBean
A subclass of EmbeddedDatabaseFactory that implements FactoryBean for registration as a Spring bean. Returns the actual DataSource that provides connectivity to the embedded database to Spring. The target DataSource is returned instead of an EmbeddedDatabase proxy since the FactoryBean will manage the initialization and destruction lifecycle of the embedded database instance. Implements DisposableBean to shutdown the embedded database when the managing Spring container is being closed. |