|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.access.DbLoader
public class DbLoader
Utility class that does reverse engineering of the database. It can create DataMaps using database meta data obtained via JDBC driver.
Field Summary | |
---|---|
protected DbAdapter |
adapter
|
protected java.sql.Connection |
connection
|
protected boolean |
creatingMeaningfulPK
|
protected DbLoaderDelegate |
delegate
|
protected java.lang.String |
genericClassName
|
protected java.sql.DatabaseMetaData |
metaData
|
protected NamingStrategy |
namingStrategy
Strategy for choosing names for entities, attributes and relationships |
static java.lang.String |
WILDCARD
|
Constructor Summary | |
---|---|
DbLoader(java.sql.Connection connection,
DbAdapter adapter,
DbLoaderDelegate delegate)
Creates new DbLoader. |
|
DbLoader(java.sql.Connection connection,
DbAdapter adapter,
DbLoaderDelegate delegate,
NamingStrategy strategy)
Creates new DbLoader with specified naming strategy. |
Method Summary | |
---|---|
DbAdapter |
getAdapter()
Returns DbAdapter associated with this DbLoader. |
java.util.List<java.lang.String> |
getCatalogs()
Retrieves catalogues for the database associated with this DbLoader. |
java.sql.Connection |
getConnection()
Returns database connection used by this DbLoader. |
java.lang.String |
getGenericClassName()
Returns a name of a generic class that should be used for all ObjEntities. |
java.sql.DatabaseMetaData |
getMetaData()
Returns DatabaseMetaData object associated with this DbLoader. |
NamingStrategy |
getNamingStrategy()
|
java.util.List<java.lang.String> |
getSchemas()
Retrieves the schemas for the database. |
java.util.List<DbEntity> |
getTables(java.lang.String catalogPattern,
java.lang.String schemaPattern,
java.lang.String tableNamePattern,
java.lang.String[] types)
Returns all tables for given combination of the criteria. |
java.util.List<java.lang.String> |
getTableTypes()
Returns all the table types for the given database. |
boolean |
includeTableName(java.lang.String tableName)
A method that return true if the given table name should be included. |
boolean |
isCreatingMeaningfulPK()
Returns true if the generator should map all primary key columns as ObjAttributes. |
DataMap |
loadDataMapFromDB(java.lang.String schemaName,
java.lang.String tablePattern,
DataMap dataMap)
Performs database reverse engineering and generates DataMap that contains default mapping of the tables and views. |
DataMap |
loadDataMapFromDB(java.lang.String schemaName,
java.lang.String tablePattern,
java.lang.String[] tableTypes,
DataMap dataMap)
Performs database reverse engineering and generates DataMap object that contains default mapping of the tables and views. |
boolean |
loadDbEntities(DataMap map,
java.util.List<? extends DbEntity> tables)
Loads dbEntities for the specified tables. |
void |
loadDbRelationships(DataMap map)
Loads database relationships into a DataMap. |
void |
loadObjEntities(DataMap map)
Creates an ObjEntity for each DbEntity in the map. |
void |
loadProceduresFromDB(java.lang.String schemaPattern,
java.lang.String namePattern,
DataMap dataMap)
Loads database stored procedures into the DataMap. |
protected void |
postprocessMasterDbRelationship(DbRelationship relationship,
ExportedKey key)
Detects correct relationship multiplicity and "to dep pk" flag. |
void |
setCreatingMeaningfulPK(boolean check)
|
void |
setGenericClassName(java.lang.String genericClassName)
Sets a name of a generic class that should be used for all ObjEntities. |
void |
setNamingStrategy(NamingStrategy strategy)
Sets new naming strategy for reverse engineering |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String WILDCARD
protected java.sql.Connection connection
protected DbAdapter adapter
protected java.sql.DatabaseMetaData metaData
protected DbLoaderDelegate delegate
protected java.lang.String genericClassName
protected boolean creatingMeaningfulPK
protected NamingStrategy namingStrategy
Constructor Detail |
---|
public DbLoader(java.sql.Connection connection, DbAdapter adapter, DbLoaderDelegate delegate)
public DbLoader(java.sql.Connection connection, DbAdapter adapter, DbLoaderDelegate delegate, NamingStrategy strategy)
Method Detail |
---|
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
java.sql.SQLException
public void setCreatingMeaningfulPK(boolean check)
public boolean isCreatingMeaningfulPK()
public java.sql.Connection getConnection()
public java.lang.String getGenericClassName()
CayenneDataObject
. If generic
class name is null (which is the default), DbLoader will assign each entity a
unique class name derived from the table name.
public void setGenericClassName(java.lang.String genericClassName)
CayenneDataObject
. If generic
class name is set to null (which is the default), DbLoader will assign each entity
a unique class name derived from the table name.
public DbAdapter getAdapter()
public boolean includeTableName(java.lang.String tableName)
public java.util.List<java.lang.String> getCatalogs() throws java.sql.SQLException
java.sql.SQLException
public java.util.List<java.lang.String> getSchemas() throws java.sql.SQLException
java.sql.SQLException
public java.util.List<java.lang.String> getTableTypes() throws java.sql.SQLException
java.sql.SQLException
public java.util.List<DbEntity> getTables(java.lang.String catalogPattern, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.String[] types) throws java.sql.SQLException
catalogPattern
- The name of the catalog, may be null.schemaPattern
- The pattern for schema name, use "%" for wildcard.tableNamePattern
- The pattern for table names, % for wildcard, if null or ""
defaults to "%".types
- The types of table names to retrieve, null returns all types.
java.sql.SQLException
public boolean loadDbEntities(DataMap map, java.util.List<? extends DbEntity> tables) throws java.sql.SQLException
map
- DataMap to be populated with DbEntities.tables
- The list of org.apache.cayenne.ashwood.dbutil.Table objects for which
DbEntities must be created.
java.sql.SQLException
public void loadObjEntities(DataMap map)
public void loadDbRelationships(DataMap map) throws java.sql.SQLException
java.sql.SQLException
protected void postprocessMasterDbRelationship(DbRelationship relationship, ExportedKey key)
public DataMap loadDataMapFromDB(java.lang.String schemaName, java.lang.String tablePattern, DataMap dataMap) throws java.sql.SQLException
java.sql.SQLException
public DataMap loadDataMapFromDB(java.lang.String schemaName, java.lang.String tablePattern, java.lang.String[] tableTypes, DataMap dataMap) throws java.sql.SQLException
java.sql.SQLException
public void loadProceduresFromDB(java.lang.String schemaPattern, java.lang.String namePattern, DataMap dataMap) throws java.sql.SQLException
As of 1.1 there is no boolean property or delegate method to make procedure loading optional or to implement custom merging logic, so currently this method is NOT CALLED from "loadDataMapFromDB" and should be invoked explicitly by the user.
java.sql.SQLException
public void setNamingStrategy(NamingStrategy strategy)
public NamingStrategy getNamingStrategy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |