|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.access.DbGenerator
public class DbGenerator
Utility class that generates database schema based on Cayenne mapping. It is a logical counterpart of DbLoader class.
Field Summary | |
---|---|
protected DbAdapter |
adapter
|
protected java.util.Map |
createFK
|
protected java.util.List |
createPK
|
protected java.util.Map |
createTables
|
protected java.util.List |
dbEntitiesInInsertOrder
Contains all DbEntities ordered considering their interdependencies. |
protected java.util.List |
dbEntitiesRequiringAutoPK
|
protected DataDomain |
domain
|
protected java.util.List |
dropPK
|
protected java.util.Map |
dropTables
|
protected ValidationResult |
failures
|
protected DataMap |
map
|
protected boolean |
shouldCreateFKConstraints
|
protected boolean |
shouldCreatePKSupport
|
protected boolean |
shouldCreateTables
|
protected boolean |
shouldDropPKSupport
|
protected boolean |
shouldDropTables
|
Constructor Summary | |
---|---|
DbGenerator(DbAdapter adapter,
DataMap map)
Creates and initializes new DbGenerator. |
|
DbGenerator(DbAdapter adapter,
DataMap map,
java.util.Collection excludedEntities)
Creates and initializes new DbGenerator instance. |
|
DbGenerator(DbAdapter adapter,
DataMap map,
java.util.Collection excludedEntities,
DataDomain domain)
Creates and initializes new DbGenerator instance. |
Method Summary | |
---|---|
protected void |
buildStatements()
Creates and stores internally a set of statements for database schema creation, ignoring configured schema creation preferences. |
java.util.List |
configuredStatements()
Returns a list of all schema statements that should be executed with the current configuration. |
java.util.List |
createFkConstraintsQueries(DbEntity dbEnt)
Returns an array of queries to create foreign key constraints for a particular DbEntity. |
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(javax.sql.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(java.sql.Connection connection,
java.lang.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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DbAdapter adapter
protected DataMap map
protected DataDomain domain
protected java.util.Map dropTables
protected java.util.Map createTables
protected java.util.Map createFK
protected java.util.List createPK
protected java.util.List dropPK
protected java.util.List dbEntitiesInInsertOrder
protected java.util.List dbEntitiesRequiringAutoPK
protected boolean shouldDropTables
protected boolean shouldCreateTables
protected boolean shouldDropPKSupport
protected boolean shouldCreatePKSupport
protected boolean shouldCreateFKConstraints
protected ValidationResult failures
Constructor Detail |
---|
public DbGenerator(DbAdapter adapter, DataMap map)
public DbGenerator(DbAdapter adapter, DataMap map, java.util.Collection excludedEntities)
adapter
- DbAdapter corresponding to the databasemap
- DataMap whose entities will be used in schema generationexcludedEntities
- entities that should be ignored during schema generationpublic DbGenerator(DbAdapter adapter, DataMap map, java.util.Collection excludedEntities, DataDomain domain)
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.Method Detail |
---|
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 java.util.List configuredStatements()
public void runGenerator(DataSourceInfo dsi) throws java.lang.Exception
public void runGenerator(DataSource ds)
.
java.lang.Exception
public void runGenerator(javax.sql.DataSource ds) throws java.lang.Exception
java.lang.Exception
protected boolean safeExecute(java.sql.Connection connection, java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public java.util.List createFkConstraintsQueries(DbEntity dbEnt)
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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |