public class DbGenerator extends Object
Modifier and Type | Field and Description |
---|---|
protected DbAdapter |
adapter |
protected Map<String,List<String>> |
createConstraints |
protected List<String> |
createPK |
protected Map<String,String> |
createTables |
protected List<DbEntity> |
dbEntitiesInInsertOrder
Contains all DbEntities ordered considering their interdependencies.
|
protected List<DbEntity> |
dbEntitiesRequiringAutoPK |
protected DataDomain |
domain |
protected List<String> |
dropPK |
protected Map<String,Collection<String>> |
dropTables |
protected ValidationResult |
failures |
protected JdbcEventLogger |
jdbcEventLogger |
protected DataMap |
map |
protected boolean |
shouldCreateFKConstraints |
protected boolean |
shouldCreatePKSupport |
protected boolean |
shouldCreateTables |
protected boolean |
shouldDropPKSupport |
protected boolean |
shouldDropTables |
Constructor and Description |
---|
DbGenerator(DbAdapter adapter,
DataMap map,
Collection<DbEntity> excludedEntities,
DataDomain domain,
JdbcEventLogger logger)
Creates and initializes new DbGenerator instance.
|
DbGenerator(DbAdapter adapter,
DataMap map,
JdbcEventLogger logger) |
DbGenerator(DbAdapter adapter,
DataMap map,
JdbcEventLogger logger,
Collection<DbEntity> excludedEntities) |
Modifier and Type | Method and Description |
---|---|
protected void |
buildStatements()
Creates and stores internally a set of statements for database schema
creation, ignoring configured schema creation preferences.
|
List<String> |
configuredStatements()
Returns a list of all schema statements that should be executed with the
current configuration.
|
List<String> |
createConstraintsQueries(DbEntity table)
Creates FK and UNIQUE constraint statements for a given table.
|
DbAdapter |
getAdapter()
Returns DbAdapter associated with this DbGenerator.
|
DataDomain |
getDomain()
Returns a DataDomain used by the DbGenerator to detect cross-database
relationships.
|
ValidationResult |
getFailures()
Returns an object representing a collection of failures that occurred on
the last "runGenerator" invocation, or null if there were no failures.
|
boolean |
isEmpty(boolean respectConfiguredSettings)
Returns
true if there is nothing to be done by this
generator. |
protected void |
resetToDefaults() |
void |
runGenerator(DataSource ds)
Executes a set of commands to drop/create database objects.
|
void |
runGenerator(DataSourceInfo dsi)
Creates a temporary DataSource out of DataSourceInfo and invokes
public void runGenerator(DataSource ds) . |
protected boolean |
safeExecute(Connection connection,
String sql)
Builds and executes a SQL statement, catching and storing SQL exceptions
resulting from invalid SQL.
|
void |
setShouldCreateFKConstraints(boolean shouldCreateFKConstraints) |
void |
setShouldCreatePKSupport(boolean shouldCreatePKSupport) |
void |
setShouldCreateTables(boolean shouldCreateTables) |
void |
setShouldDropPKSupport(boolean shouldDropPKSupport) |
void |
setShouldDropTables(boolean shouldDropTables) |
boolean |
shouldCreateFKConstraints() |
boolean |
shouldCreatePKSupport()
Returns whether DbGenerator is configured to create primary key support
for DataMap entities.
|
boolean |
shouldCreateTables()
Returns whether DbGenerator is configured to create tables for DataMap
entities.
|
boolean |
shouldDropPKSupport() |
boolean |
shouldDropTables() |
protected DbAdapter adapter
protected DataMap map
protected DataDomain domain
protected JdbcEventLogger jdbcEventLogger
protected Map<String,Collection<String>> dropTables
protected List<DbEntity> dbEntitiesInInsertOrder
protected boolean shouldDropTables
protected boolean shouldCreateTables
protected boolean shouldDropPKSupport
protected boolean shouldCreatePKSupport
protected boolean shouldCreateFKConstraints
protected ValidationResult failures
public DbGenerator(DbAdapter adapter, DataMap map, JdbcEventLogger logger)
public DbGenerator(DbAdapter adapter, DataMap map, JdbcEventLogger logger, Collection<DbEntity> excludedEntities)
public DbGenerator(DbAdapter adapter, DataMap map, Collection<DbEntity> excludedEntities, DataDomain domain, JdbcEventLogger logger)
adapter
- DbAdapter corresponding to the databasemap
- DataMap whose entities will be used in schema generationexcludedEntities
- entities that should be ignored during schema generationdomain
- optional DataDomain used to detect cross-database
relationships.protected void resetToDefaults()
protected void buildStatements()
public boolean isEmpty(boolean respectConfiguredSettings)
true
if there is nothing to be done by this
generator. If respectConfiguredSettings
is true
, checks are done applying currently configured settings, otherwise check
is done, assuming that all possible generated objects.public DbAdapter getAdapter()
public List<String> configuredStatements()
public void runGenerator(DataSourceInfo dsi) throws Exception
public void runGenerator(DataSource ds)
.Exception
public void runGenerator(DataSource ds) throws Exception
Exception
protected boolean safeExecute(Connection connection, String sql) throws SQLException
SQLException
public List<String> createConstraintsQueries(DbEntity table)
public ValidationResult getFailures()
public boolean shouldCreatePKSupport()
public boolean shouldCreateTables()
public boolean shouldDropPKSupport()
public boolean shouldDropTables()
public boolean shouldCreateFKConstraints()
public void setShouldCreatePKSupport(boolean shouldCreatePKSupport)
public void setShouldCreateTables(boolean shouldCreateTables)
public void setShouldDropPKSupport(boolean shouldDropPKSupport)
public void setShouldDropTables(boolean shouldDropTables)
public void setShouldCreateFKConstraints(boolean shouldCreateFKConstraints)
public DataDomain getDomain()
Copyright © 2001–2017 Apache Cayenne. All rights reserved.