public class DbLoader extends Object
| Modifier and Type | Field and Description |
|---|---|
protected DbAdapter |
adapter |
protected Connection |
connection |
protected boolean |
creatingMeaningfulPK |
protected DbLoaderDelegate |
delegate |
protected String |
genericClassName |
protected DatabaseMetaData |
metaData |
protected NamingStrategy |
namingStrategy
Strategy for choosing names for entities, attributes and relationships
|
static String |
WILDCARD |
| Constructor and Description |
|---|
DbLoader(Connection connection,
DbAdapter adapter,
DbLoaderDelegate delegate)
Creates new DbLoader.
|
DbLoader(Connection connection,
DbAdapter adapter,
DbLoaderDelegate delegate,
NamingStrategy strategy)
Creates new DbLoader with specified naming strategy.
|
| Modifier and Type | Method and Description |
|---|---|
DbAdapter |
getAdapter()
Returns DbAdapter associated with this DbLoader.
|
List<String> |
getCatalogs()
Retrieves catalogues for the database associated with this DbLoader.
|
Connection |
getConnection()
Returns database connection used by this DbLoader.
|
String |
getGenericClassName()
Returns a name of a generic class that should be used for all ObjEntities.
|
DatabaseMetaData |
getMetaData()
Returns DatabaseMetaData object associated with this DbLoader.
|
NamingStrategy |
getNamingStrategy() |
List<String> |
getSchemas()
Retrieves the schemas for the database.
|
List<DbEntity> |
getTables(String catalogPattern,
String schemaPattern,
String tableNamePattern,
String[] types)
Returns all tables for given combination of the criteria.
|
List<String> |
getTableTypes()
Returns all the table types for the given database.
|
boolean |
includeTableName(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(String schemaName,
String tablePattern,
DataMap dataMap)
Performs database reverse engineering and generates DataMap that contains default
mapping of the tables and views.
|
DataMap |
loadDataMapFromDB(String schemaName,
String tablePattern,
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,
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(String schemaPattern,
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(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
|
public static final String WILDCARD
protected Connection connection
protected DbAdapter adapter
protected DatabaseMetaData metaData
protected DbLoaderDelegate delegate
protected String genericClassName
protected boolean creatingMeaningfulPK
protected NamingStrategy namingStrategy
public DbLoader(Connection connection, DbAdapter adapter, DbLoaderDelegate delegate)
public DbLoader(Connection connection, DbAdapter adapter, DbLoaderDelegate delegate, NamingStrategy strategy)
public DatabaseMetaData getMetaData() throws SQLException
SQLExceptionpublic void setCreatingMeaningfulPK(boolean check)
public boolean isCreatingMeaningfulPK()
public Connection getConnection()
public 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(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(String tableName)
public List<String> getCatalogs() throws SQLException
SQLExceptionpublic List<String> getSchemas() throws SQLException
SQLExceptionpublic List<String> getTableTypes() throws SQLException
SQLExceptionpublic List<DbEntity> getTables(String catalogPattern, String schemaPattern, String tableNamePattern, String[] types) throws 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.SQLExceptionpublic boolean loadDbEntities(DataMap map, List<? extends DbEntity> tables) throws 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.SQLExceptionpublic void loadObjEntities(DataMap map)
public void loadDbRelationships(DataMap map) throws SQLException
SQLExceptionprotected void postprocessMasterDbRelationship(DbRelationship relationship, ExportedKey key)
public DataMap loadDataMapFromDB(String schemaName, String tablePattern, DataMap dataMap) throws SQLException
SQLExceptionpublic DataMap loadDataMapFromDB(String schemaName, String tablePattern, String[] tableTypes, DataMap dataMap) throws SQLException
SQLExceptionpublic void loadProceduresFromDB(String schemaPattern, String namePattern, DataMap dataMap) throws 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.
SQLExceptionpublic void setNamingStrategy(NamingStrategy strategy)
public NamingStrategy getNamingStrategy()
Copyright © 2001–2018 Apache Cayenne. All rights reserved.