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
ConstructorDescriptionCreate an emptyCompositeDatabasePopulator
.CompositeDatabasePopulator
(Collection<DatabasePopulator> populators) Create aCompositeDatabasePopulator
with the given populators.CompositeDatabasePopulator
(DatabasePopulator... populators) Create aCompositeDatabasePopulator
with the given populators. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPopulators
(DatabasePopulator... populators) Add one or more populators to the list of delegates.void
populate
(Connection connection) Populate, initialize, or clean up the database using the provided JDBC connection.void
setPopulators
(DatabasePopulator... populators) Specify one or more populators to delegate to.
-
Constructor Details
-
CompositeDatabasePopulator
public CompositeDatabasePopulator()Create an emptyCompositeDatabasePopulator
. -
CompositeDatabasePopulator
Create aCompositeDatabasePopulator
with the given populators.- Parameters:
populators
- one or more populators to delegate to- Since:
- 4.3
-
CompositeDatabasePopulator
Create aCompositeDatabasePopulator
with 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:DatabasePopulator
Populate, initialize, or clean up the database using the provided JDBC connection.Concrete implementations may throw an
SQLException
if an error is encountered but are strongly encouraged to throw a specificScriptException
instead. For example, Spring'sResourceDatabasePopulator
andDatabasePopulatorUtils
wrap allSQLExceptions
inScriptExceptions
.- Specified by:
populate
in interfaceDatabasePopulator
- Parameters:
connection
- the JDBC connection to use to populate the db; already configured and ready to use; nevernull
- Throws:
SQLException
- if an unrecoverable data access exception occurs during database populationScriptException
- in all other error cases- See Also:
-