public class CompositeDatabasePopulator extends java.lang.Object implements DatabasePopulator
DatabasePopulator
that delegates to a list of given
DatabasePopulator
implementations, executing all scripts.Constructor and Description |
---|
CompositeDatabasePopulator()
Create an empty
CompositeDatabasePopulator . |
CompositeDatabasePopulator(java.util.Collection<DatabasePopulator> populators)
Create a
CompositeDatabasePopulator with the given populators. |
CompositeDatabasePopulator(DatabasePopulator... populators)
Create a
CompositeDatabasePopulator with the given populators. |
Modifier and Type | Method and Description |
---|---|
void |
addPopulators(DatabasePopulator... populators)
Add one or more populators to the list of delegates.
|
void |
populate(java.sql.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.
|
public CompositeDatabasePopulator()
CompositeDatabasePopulator
.public CompositeDatabasePopulator(java.util.Collection<DatabasePopulator> populators)
CompositeDatabasePopulator
with the given populators.populators
- one or more populators to delegate topublic CompositeDatabasePopulator(DatabasePopulator... populators)
CompositeDatabasePopulator
with the given populators.populators
- one or more populators to delegate topublic void setPopulators(DatabasePopulator... populators)
public void addPopulators(DatabasePopulator... populators)
public void populate(java.sql.Connection connection) throws java.sql.SQLException, ScriptException
DatabasePopulator
Concrete implementations may throw an SQLException
if
an error is encountered but are strongly encouraged to throw a
specific ScriptException
instead. For example, Spring's
ResourceDatabasePopulator
and DatabasePopulatorUtils
wrap
all SQLExceptions
in ScriptExceptions
.
populate
in interface DatabasePopulator
connection
- the JDBC connection to use to populate the db; already
configured and ready to use; never null
java.sql.SQLException
- if an unrecoverable data access exception occurs
during database populationScriptException
- in all other error casesDatabasePopulatorUtils.execute(org.springframework.jdbc.datasource.init.DatabasePopulator, javax.sql.DataSource)