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.Warning: Concrete implementations should not close the provided
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; 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:
-