Class CompositeDatabasePopulator
java.lang.Object
org.springframework.jdbc.datasource.init.CompositeDatabasePopulator
- All Implemented Interfaces:
DatabasePopulator
Composite
DatabasePopulator that delegates to a list of given
DatabasePopulator implementations, executing all scripts.- Since:
- 3.1
- Author:
- Dave Syer, Juergen Hoeller, Sam Brannen, Kazuki Shimizu
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an emptyCompositeDatabasePopulator.CompositeDatabasePopulator(Collection<DatabasePopulator> populators) Create aCompositeDatabasePopulatorwith the given populators.CompositeDatabasePopulator(DatabasePopulator... populators) Create aCompositeDatabasePopulatorwith the given populators. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPopulators(DatabasePopulator... populators) Add one or more populators to the list of delegates.voidpopulate(Connection connection) Populate, initialize, or clean up the database using the provided JDBC connection.voidsetPopulators(DatabasePopulator... populators) Specify one or more populators to delegate to.
-
Constructor Details
-
CompositeDatabasePopulator
public CompositeDatabasePopulator()Create an emptyCompositeDatabasePopulator. -
CompositeDatabasePopulator
Create aCompositeDatabasePopulatorwith the given populators.- Parameters:
populators- one or more populators to delegate to- Since:
- 4.3
-
CompositeDatabasePopulator
Create aCompositeDatabasePopulatorwith the given populators.- Parameters:
populators- one or more populators to delegate to- Since:
- 4.3
-
-
Method Details
-
setPopulators
Specify one or more populators to delegate to. -
addPopulators
Add one or more populators to the list of delegates. -
populate
Description copied from interface:DatabasePopulatorPopulate, initialize, or clean up the database using the provided JDBC connection.Warning: Concrete implementations should not close the provided
Connection.Concrete implementations may throw an
SQLExceptionif an error is encountered but are strongly encouraged to throw a specificScriptExceptioninstead. For example, Spring'sResourceDatabasePopulatorandDatabasePopulatorUtilswrap allSQLExceptionsinScriptExceptions.- Specified by:
populatein interfaceDatabasePopulator- Parameters:
connection- the JDBC connection to use; already configured and ready to use; nevernull- Throws:
SQLException- if an unrecoverable data access exception occurs while interacting with the databaseScriptException- in all other error cases- See Also:
-