com.triactive.jdo
Interface SchemaManager

All Superinterfaces:
SchemaManagementOptions

public interface SchemaManager
extends SchemaManagementOptions

An interface to perform limited storage management on a database schema used by TJDO. This interface extends SchemaManagementOptions and allows management options to be modified. Any changes made only affect operations performed using the same schema manager, and otherwise have no effect on operations performed through the normal JDO API.

Author:
Mike Martin
See Also:
SchemaManagerFactory

Method Summary
 void addClasses(java.lang.Class[] classes)
          Adds to the schema any database objects (tables, views, constraints, indexes, etc.) necessary to enable persistence of the given PersistenceCapable class(es).
 void dropAllTables()
          Drops all tables in the schema.
 void dropTablesFor(java.lang.Class[] classes)
          Removes from the schema any existing database tables used in persisting the given PersistenceCapable class(es).
 java.lang.String getCatalogName()
          Returns the name of the database catalog.
 int getClassId(java.lang.Class clazz)
          Returns the class ID number for the specified persistence-capable class.
 java.util.Date getCurrentTimestamp()
          Returns a timestamp reflecting the database's current date and time.
 java.lang.String getDatabaseUrl()
          Returns the connection URL for the database.
 java.lang.String getSchemaName()
          Returns the name of the database schema.
 void reset()
          Resets the schema manager back to its initial state.
 java.lang.Class[] storedClasses()
          Returns the set of PersistenceCapable classes currently stored in this schema.
 
Methods inherited from interface com.triactive.jdo.SchemaManagementOptions
getAutoCreateTables, getValidateConstraints, getValidateTables, setAutoCreateTables, setValidateConstraints, setValidateTables
 

Method Detail

getDatabaseUrl

public java.lang.String getDatabaseUrl()
Returns the connection URL for the database. This is the URL used to make JDBC connections to the database, as reported by the metadata of the initial connection made by TJDO.

Returns:
The connection URL
See Also:
DatabaseMetaData.getURL()

getCatalogName

public java.lang.String getCatalogName()
Returns the name of the database catalog.

Returns:
The name of the database catalog, or null if the DBMS does not support the concept of catalogs.

getSchemaName

public java.lang.String getSchemaName()
Returns the name of the database schema.

Returns:
The name of the database schema, or null if the DBMS does not support the concept of schemas.

getCurrentTimestamp

public java.util.Date getCurrentTimestamp()
Returns a timestamp reflecting the database's current date and time.

Returns:
the current timestamp of the database
Throws:
java.lang.UnsupportedOperationException - If no method is available for determining the database's current timestamp.

addClasses

public void addClasses(java.lang.Class[] classes)
Adds to the schema any database objects (tables, views, constraints, indexes, etc.) necessary to enable persistence of the given PersistenceCapable class(es). If any of the objects already exist, they are validated for structural correctness; that is, checked to ensure that they "match" the current class code and JDO metadata.

This method is primarily useful for applications that wish to perform all of their database initialization up front, rather than wait for the TJDO runtime to do it on-demand.

SQL identifiers for new database objects are chosen so as not to collide with any existing objects. Therefore it is always safe for TJDO and non-TJDO code to share the same database schema.

Parameters:
classes - The class(es) to be added.
Throws:
SchemaValidationException - If there is some mismatch between the current schema contents and those necessary to enable persistence of the given classes.

storedClasses

public java.lang.Class[] storedClasses()
Returns the set of PersistenceCapable classes currently stored in this schema. This is the set of all known classes in this schema in the data store. The set is determined by querying JDO_TABLE. "Known" in this case means both present in JDO_TABLE and visible to the schema manager's class loader(s). If there are any classes not visible to the loader they are silently omitted.

Not all of the returned classes have necessarily been initialized by TJDO's store manager. That is, some may not have been accessed yet by application code or forcibly initialized by addClasses(java.lang.Class[]). The sequence:

 schemaManager.addClasses(schemaManager.storedClasses());
 
can be used to forcibly initialize every known class in the schema.

Returns:
The set of PersistenceCapable classes currently stored in this schema.

getClassId

public int getClassId(java.lang.Class clazz)
Returns the class ID number for the specified persistence-capable class. Class IDs are a component of the object IDs used for JDO datastore identity in TJDO.

If it hasn't already been added, this method adds the specified class to the schema.

Parameters:
clazz - a persistence-capable class
Returns:
the class ID
See Also:
OID

dropTablesFor

public void dropTablesFor(java.lang.Class[] classes)
Removes from the schema any existing database tables used in persisting the given PersistenceCapable class(es).

This method will fail if the relevant tables are depended upon by others used for classes that are not being removed. In case of failure, it is unspecified whether or not any tables were actually removed.

After dropping tables this method performs an implicit reset().

Parameters:
classes - The class(es) whose tables are to be removed.

dropAllTables

public void dropAllTables()
Drops all tables in the schema. This empties the schema of all database objects managed by TJDO. All objects not managed by TJDO are left untouched.

After dropping tables this method performs an implicit reset().


reset

public void reset()
Resets the schema manager back to its initial state. This method discards all knowledge of persistent classes and the state of the schema. After reset(), all initialization procedures such as schema validation etc. will be repeated as necessary as though the JVM were starting anew.



Copyright 2001-2007 The TJDO Project All Rights Reserved.