public class DbLoader extends Object
Modifier and Type | Field and Description |
---|---|
static String |
WILDCARD |
static String |
WILDCARD_PATTERN |
Constructor and Description |
---|
DbLoader(Connection connection,
DbAdapter adapter,
DbLoaderDelegate delegate)
Creates new DbLoader.
|
DbLoader(Connection connection,
DbAdapter adapter,
DbLoaderDelegate delegate,
ObjectNameGenerator strategy)
Creates new DbLoader with specified naming strategy.
|
Modifier and Type | Method and Description |
---|---|
protected EntityMergeSupport |
createEntityMerger(DataMap map) |
static void |
flattenManyToManyRelationships(DataMap map,
Collection<ObjEntity> loadedObjEntities,
ObjectNameGenerator objectNameGenerator)
Flattens many-to-many relationships in the generated model.
|
DbAdapter |
getAdapter()
Returns DbAdapter associated with this DbLoader.
|
List<String> |
getCatalogs()
Retrieves catalogs for the database associated with this DbLoader.
|
Connection |
getConnection()
Returns database connection used by this DbLoader.
|
String[] |
getDefaultTableTypes()
By default we want to load Tables and Views for mo types
|
ObjectNameGenerator |
getNameGenerator() |
List<String> |
getSchemas()
Retrieves the schemas for the database.
|
Map<DbPath,Map<String,DbEntity>> |
getTables(DbLoaderConfiguration config,
String[] types)
Returns all tables for given combination of the criteria.
|
List<String> |
getTableTypes()
Returns all the table types for the given database.
|
boolean |
isCreatingMeaningfulPK()
Returns true if the generator should map all primary key columns as
ObjAttributes.
|
void |
load(DataMap dataMap,
DbLoaderConfiguration config)
Performs database reverse engineering based on the specified config
and fills the specified
DataMap object with DB and object mapping info.
|
DataMap |
load(DbLoaderConfiguration config)
Performs database reverse engineering to match the specified catalog,
schema, table name and table type patterns and fills the specified
DataMap object with DB and object mapping info.
|
DataMap |
loadDataMapFromDB(String schemaPattern,
String tablePattern,
DataMap dataMap)
Deprecated.
since 4.0 use
load(org.apache.cayenne.map.DataMap, DbLoaderConfiguration)
method that supports catalogs. |
DataMap |
loadDataMapFromDB(String schemaPattern,
String tablePattern,
String[] tableTypes,
DataMap dataMap)
Deprecated.
since 4.0 use
load(org.apache.cayenne.map.DataMap, DbLoaderConfiguration)
method that supports catalogs. |
List<DbEntity> |
loadDbEntities(DataMap map,
DbLoaderConfiguration config,
Map<DbPath,Map<String,DbEntity>> tables)
Loads dbEntities for the specified tables.
|
protected void |
loadDbRelationships(DbLoaderConfiguration config,
Map<DbPath,Map<String,DbEntity>> tables) |
Collection<ObjEntity> |
loadObjEntities(DataMap map,
DbLoaderConfiguration config,
Collection<DbEntity> entities)
Creates an ObjEntity for each DbEntity in the map.
|
static Collection<ObjEntity> |
loadObjEntities(DataMap map,
DbLoaderConfiguration config,
Collection<DbEntity> entities,
ObjectNameGenerator nameGenerator) |
Map<String,Procedure> |
loadProcedures(DataMap dataMap,
DbLoaderConfiguration config)
Loads database stored procedures into the DataMap.
|
void |
loadProceduresFromDB(String schemaPattern,
String namePattern,
DataMap dataMap)
Deprecated.
since 4.0 use loadProcedures(DataMap, String, String, String) that supports "catalog" pattern.
|
protected void |
postProcessMasterDbRelationship(DbRelationship relationship,
ExportedKey key)
Detects correct relationship multiplicity and "to dep pk" flag.
|
void |
prepareObjLayer(DataMap dataMap,
DbLoaderConfiguration config,
Collection<DbEntity> entities) |
void |
setCreatingMeaningfulPK(boolean creatingMeaningfulPK) |
void |
setNameGenerator(ObjectNameGenerator strategy)
Sets new naming strategy for reverse engineering
|
public static final String WILDCARD
public static final String WILDCARD_PATTERN
public DbLoader(Connection connection, DbAdapter adapter, DbLoaderDelegate delegate)
public DbLoader(Connection connection, DbAdapter adapter, DbLoaderDelegate delegate, ObjectNameGenerator strategy)
public void setCreatingMeaningfulPK(boolean creatingMeaningfulPK)
public boolean isCreatingMeaningfulPK()
public Connection getConnection()
public DbAdapter getAdapter()
public List<String> getCatalogs() throws SQLException
SQLException
public List<String> getSchemas() throws SQLException
SQLException
public List<String> getTableTypes() throws SQLException
SQLException
public Map<DbPath,Map<String,DbEntity>> getTables(DbLoaderConfiguration config, String[] types) throws SQLException
config
- types
- The types of table names to retrieve, null returns all types.SQLException
public List<DbEntity> loadDbEntities(DataMap map, DbLoaderConfiguration config, Map<DbPath,Map<String,DbEntity>> tables) throws SQLException
map
- DataMap to be populated with DbEntities.config
- tables
- The list of org.apache.cayenne.ashwood.dbutil.Table objects
for which DbEntities must be created. @return false if loading must be immediately aborted.SQLException
public Collection<ObjEntity> loadObjEntities(DataMap map, DbLoaderConfiguration config, Collection<DbEntity> entities)
public static Collection<ObjEntity> loadObjEntities(DataMap map, DbLoaderConfiguration config, Collection<DbEntity> entities, ObjectNameGenerator nameGenerator)
protected EntityMergeSupport createEntityMerger(DataMap map)
protected void loadDbRelationships(DbLoaderConfiguration config, Map<DbPath,Map<String,DbEntity>> tables) throws SQLException
SQLException
protected void postProcessMasterDbRelationship(DbRelationship relationship, ExportedKey key)
public static void flattenManyToManyRelationships(DataMap map, Collection<ObjEntity> loadedObjEntities, ObjectNameGenerator objectNameGenerator)
public String[] getDefaultTableTypes()
getTableTypes()
@Deprecated public DataMap loadDataMapFromDB(String schemaPattern, String tablePattern, DataMap dataMap) throws SQLException
load(org.apache.cayenne.map.DataMap, DbLoaderConfiguration)
method that supports catalogs.SQLException
@Deprecated public DataMap loadDataMapFromDB(String schemaPattern, String tablePattern, String[] tableTypes, DataMap dataMap) throws SQLException
load(org.apache.cayenne.map.DataMap, DbLoaderConfiguration)
method that supports catalogs.SQLException
public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException
SQLException
public void prepareObjLayer(DataMap dataMap, DbLoaderConfiguration config, Collection<DbEntity> entities)
public DataMap load(DbLoaderConfiguration config) throws SQLException
SQLException
@Deprecated public 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.
SQLException
public Map<String,Procedure> loadProcedures(DataMap dataMap, DbLoaderConfiguration config) 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.
SQLException
public void setNameGenerator(ObjectNameGenerator strategy)
public ObjectNameGenerator getNameGenerator()
Copyright © 2001–2015 Apache Cayenne. All rights reserved.