Expresso 5-6

com.jcorporate.expresso.core.db
Class TableCreator

java.lang.Object
  extended bycom.jcorporate.expresso.core.db.TableCreator

public class TableCreator
extends Object

A singleton utility class that helps create tables. It is stored as a weak reference since it will be seldom used and when done should be discarded.

Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $
Author:
Michael Rimov

Modify by Yves Henri AMAIZO


Field Summary
static String USE_CACHED_HSQL
          setup name for switch about using HSQL option for 'cached' tables (special case for hsql driver)
 
Constructor Summary
protected TableCreator()
           
 
Method Summary
 Vector createAsNeeded(Schema oneSchema, String dataContext)
          Try to do a search on each DBObject member - if we fail we know the table does not exist.
protected  void createIndices(DBObject dbObj, DBConnection providedConn, boolean shouldComplain)
          create indices, using provided connection if any, and complaining upon failure if specified
 void createTable(DBObject dbObj)
          Create the table needed by this DB Object in the database.
protected  FastStringBuffer createTableSQLDefinition(DBObject dbObj, FastStringBuffer sqlStatement)
          Create the SQL statement to create the table.
static TableCreator getInstance()
          The way to a Table Creator's Heart; or more importantly the way to get a reference to a TableCreator object.
protected  com.jcorporate.expresso.core.db.config.JDBCConfig getJDBCConfig(String dataContext)
          Protected method to get JDBC Configurations whether running Expresso Runtime or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_CACHED_HSQL

public static final String USE_CACHED_HSQL
setup name for switch about using HSQL option for 'cached' tables (special case for hsql driver)

See Also:
Constant Field Values
Constructor Detail

TableCreator

protected TableCreator()
Method Detail

getInstance

public static TableCreator getInstance()
The way to a Table Creator's Heart; or more importantly the way to get a reference to a TableCreator object. The implementation doesn't care how hard it is to create a TableCreator instance since it is seldom used.

Returns:
a TableCreator instance.

createTable

public void createTable(DBObject dbObj)
                 throws DBException
Create the table needed by this DB Object in the database. Assumes it is not there already. This method is used by the Schema object when called from the DBCreate servlet to initialize a database to match the defined DB objects in a schema.

Parameters:
dbObj - The Instantiated Database Object to check against.
Throws:
DBException - If there's an error creating the table with the database
Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

createTableSQLDefinition

protected FastStringBuffer createTableSQLDefinition(DBObject dbObj,
                                                    FastStringBuffer sqlStatement)
                                             throws DBException
Create the SQL statement to create the table.

Parameters:
dbObj - the dbobject where we get the parameters from.
sqlStatement - the initialized FastStringBuffer that we're going to append to. The return value is the same we pass in. Allocation and deallocation is up to the parent calling this function.
Returns:
FastStringBuffer with the create statements added
Throws:
DBException - upon creation error

Modify by Yves Henri AMAIZO

Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

createAsNeeded

public Vector createAsNeeded(Schema oneSchema,
                             String dataContext)
                      throws DBException
Try to do a search on each DBObject member - if we fail we know the table does not exist. Create it

Parameters:
oneSchema - The schema to create tables for.
dataContext - The database context to create the tables.
Returns:
A Vector containing the created dbObjects

Modify by Yves Henri AMAIZO

Throws:
DBException - If the create process fails
Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

getJDBCConfig

protected com.jcorporate.expresso.core.db.config.JDBCConfig getJDBCConfig(String dataContext)
                                                                   throws DBException
Protected method to get JDBC Configurations whether running Expresso Runtime or not.

Parameters:
dataContext - the Data Context to get the configuration for.
Returns:
JDBCConfig for the specified data context.
Throws:
DBException - if there is an error retrieving the JDBC configuration data.

createIndices

protected void createIndices(DBObject dbObj,
                             DBConnection providedConn,
                             boolean shouldComplain)
                      throws DBException
create indices, using provided connection if any, and complaining upon failure if specified

Parameters:
dbObj - the object whose indices will be created
providedConn - any db connection we should use. can be null, in which case we get/dispose of one internally
shouldComplain - whether we should log a warning if index cannot be created. use 'false' if you are checking established dbobjects, and should not complain if all of the indices already exist
Throws:
DBException - upon error

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.