|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.torque.map.DatabaseMap
public class DatabaseMap
DatabaseMap is used to model a database.
Field Summary | |
---|---|
static String |
INIT_CLASS_NAME_FORMAT
Format used to create create the class name for initializing a DB specific map |
static char |
SCHEMA_SEPARATOR_CHAR
The character which separates the schema name from the table name. |
static char |
STD_SEPARATOR_CHAR
The character used by most implementations as the separator between name elements. |
Constructor Summary | |
---|---|
DatabaseMap(Database database)
Constructs a new DatabaseMap. |
Method Summary | |
---|---|
TableMap |
addTable(String tableName)
Add a new table to the database by name. |
boolean |
containsTable(String name)
Does this database contain this specific table? |
boolean |
containsTable(TableMap table)
Does this database contain this specific table? |
void |
copyFrom(DatabaseMap databaseMap)
Copy all settings except the database from another database map. |
String |
getOption(String key)
Returns the value of an option. |
Map<String,String> |
getOptions()
Returns an unmodifiable map of all options. |
TableMap |
getTable(String name)
Get a TableMap for the table by name. |
TableMap[] |
getTables()
Get a TableMap[] of all of the tables in the database. |
void |
initialize()
Fully populate this DatabaseMap with all the TablesMaps. |
protected String |
javanameMethod(String schemaName)
Converts a database schema name to java object name. |
void |
setIdTable(TableMap idTableMap)
Add a new TableMap to the database. |
void |
setOption(String key,
String value)
Sets an option. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final char STD_SEPARATOR_CHAR
public static final char SCHEMA_SEPARATOR_CHAR
public static final String INIT_CLASS_NAME_FORMAT
Constructor Detail |
---|
public DatabaseMap(Database database)
Method Detail |
---|
public boolean containsTable(TableMap table)
table
- The TableMap representation of the table.
public boolean containsTable(String name)
name
- The String representation of the table.
public TableMap getTable(String name)
Note that by default Torque uses lazy initialization to minimize memory usage and startup time. However, if an OM or PEER class has not called the table's MapBuilder class, it will not be here. See the optional initialize method if you need full OM Mapping.
name
- Name of the table.
public TableMap[] getTables()
Note that by default Torque uses lazy initialization to minimize memory usage and startup time. However, if an OM or PEER class has not called the table's MapBuilder class, it will not be here. See the optional initialize method if you need full OM Mapping.
public TableMap addTable(String tableName)
tableName
- The name of the table.
public void setIdTable(TableMap idTableMap)
idTableMap
- The TableMap representation.public Map<String,String> getOptions()
public void setOption(String key, String value)
key
- the key of the optionvalue
- the value of the option.public String getOption(String key)
key
- the key of the option.
public void initialize() throws TorqueException
DatabaseMap dbMap = Torque.getDatabaseMap( dbName );
try {
dbMap.initialize();
} catch ( TorqueException e ) {
... error handling
}
Note that Torque database names are case sensitive and this DB
map must be retrieved with the exact name used in the XML schema.
This uses Java reflection methods to locate and run the init() method of a class generated in the org.apache.torque.linkage package with a name based on the XML Database name value, e.g. org.apache.torque.linkage.DefaultMapInit
Some misconfiguration situations that could cause this method to fail are:
The class(es) in the org.apache.torque.linkage package were not included with the other generated class files (e.g. the jar file creation process only included com.* and not org.* files).
TorqueException
- If an error is encountered locating and calling
the init method.protected String javanameMethod(String schemaName)
schemaName
- name to be converted.
public void copyFrom(DatabaseMap databaseMap)
databaseMap
- the database map to copy from, not null.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |