Class Database
java.lang.Object
edu.internet2.middleware.grouper.ext.org.apache.ddlutils.model.Database
- All Implemented Interfaces:
Serializable
,Cloneable
Represents the database model, ie. the tables in the database. It also
contains the corresponding dyna classes for creating dyna beans for the
objects stored in the tables.
- Version:
- $Revision: 504014 $
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a table at the specified position.void
Adds a table.void
addTables
(Collection tables) Adds the given tables.clone()
org.apache.commons.beanutils.DynaBean
createDynaBeanFor
(Table table) Creates a new dyna bean for the given table.org.apache.commons.beanutils.DynaBean
createDynaBeanFor
(String tableName, boolean caseSensitive) Convenience method that combinescreateDynaBeanFor(Table)
andfindTable(String, boolean)
.boolean
Finds the table with the specified name, using case insensitive matching.Finds the table with the specified name, using case insensitive matching.getDynaClassFor
(String tableName) Returns theorg.apache.ddlutils.dynabean.SqlDynaClass
for the given table name.getDynaClassFor
(org.apache.commons.beanutils.DynaBean bean) Returns theorg.apache.ddlutils.dynabean.SqlDynaClass
for the given dyna bean.Returns the method for generating primary key values.getName()
Returns the name of this database model.getTable
(int idx) Returns the table at the specified position.int
Returns the number of tables in this model.Table[]
Returns the tables in this model.Returns the version of this database model.int
hashCode()
void
Initializes the model by establishing the relationships between elements in this model encoded eg.void
Adds all tables from the other database to this database.void
removeTable
(int idx) Removes the indicated table.void
removeTable
(Table table) Removes the given table.void
Resets the dyna class cache.void
setIdMethod
(String idMethod) Sets the method for generating primary key values.void
Sets the name of this database model.void
setVersion
(String version) Sets the version of this database model.toString()
Returns a verbose string representation of this database.
-
Constructor Details
-
Database
public Database()
-
-
Method Details
-
mergeWith
Adds all tables from the other database to this database. Note that the other database is not changed.- Parameters:
otherDb
- The other database model- Throws:
ModelException
-
getName
Returns the name of this database model.- Returns:
- The name
-
setName
Sets the name of this database model.- Parameters:
name
- The name
-
getVersion
Returns the version of this database model.- Returns:
- The version
-
setVersion
Sets the version of this database model.- Parameters:
version
- The version
-
getIdMethod
Returns the method for generating primary key values.- Returns:
- The method
-
setIdMethod
Sets the method for generating primary key values. Note that this value is ignored by DdlUtils and only for compatibility with Torque.- Parameters:
idMethod
- The method
-
getTableCount
public int getTableCount()Returns the number of tables in this model.- Returns:
- The number of tables
-
getTables
Returns the tables in this model.- Returns:
- The tables
-
getTable
Returns the table at the specified position.- Parameters:
idx
- The index of the table- Returns:
- The table
-
addTable
Adds a table.- Parameters:
table
- The table to add
-
addTable
Adds a table at the specified position.- Parameters:
idx
- The index where to insert the tabletable
- The table to add
-
addTables
Adds the given tables.- Parameters:
tables
- The tables to add
-
removeTable
Removes the given table.- Parameters:
table
- The table to remove
-
removeTable
public void removeTable(int idx) Removes the indicated table.- Parameters:
idx
- The index of the table to remove
-
initialize
Initializes the model by establishing the relationships between elements in this model encoded eg. in foreign keys etc. Also checks that the model elements are valid (table and columns have a name, foreign keys rference existing tables etc.)- Throws:
ModelException
-
findTable
Finds the table with the specified name, using case insensitive matching. Note that this method is not called getTable to avoid introspection problems.- Parameters:
name
- The name of the table to find- Returns:
- The table or
null
if there is no such table
-
findTable
Finds the table with the specified name, using case insensitive matching. Note that this method is not called getTable) to avoid introspection problems.- Parameters:
name
- The name of the table to findcaseSensitive
- Whether case matters for the names- Returns:
- The table or
null
if there is no such table
-
resetDynaClassCache
public void resetDynaClassCache()Resets the dyna class cache. This should be done for instance when a column has been added or removed to a table. -
getDynaClassFor
Returns theorg.apache.ddlutils.dynabean.SqlDynaClass
for the given table name. If the it does not exist yet, a new one will be created based on the Table definition.- Parameters:
tableName
- The name of the table to create the bean for- Returns:
- The
SqlDynaClass
for the indicated table ornull
if the model contains no such table
-
getDynaClassFor
Returns theorg.apache.ddlutils.dynabean.SqlDynaClass
for the given dyna bean.- Parameters:
bean
- The dyna bean- Returns:
- The
SqlDynaClass
for the given bean
-
createDynaBeanFor
Creates a new dyna bean for the given table.- Parameters:
table
- The table to create the bean for- Returns:
- The new dyna bean
- Throws:
SqlDynaException
-
createDynaBeanFor
public org.apache.commons.beanutils.DynaBean createDynaBeanFor(String tableName, boolean caseSensitive) throws SqlDynaException Convenience method that combinescreateDynaBeanFor(Table)
andfindTable(String, boolean)
.- Parameters:
tableName
- The name of the table to create the bean forcaseSensitive
- Whether case matters for the names- Returns:
- The new dyna bean
- Throws:
SqlDynaException
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
equals
-
hashCode
public int hashCode() -
toString
-
toVerboseString
Returns a verbose string representation of this database.- Returns:
- The string representation
-