|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jpox.store.rdbms.table.AbstractTable
public abstract class AbstractTable
Abstract implementation of a table in the datastore. The table exists in various states. After initialisation it can be created in the datastore by calling create. At any point after initialisation it can be modified, but only by addition of columns. The table can be dropped from the datastore by calling drop.
| Field Summary | |
|---|---|
protected java.util.List |
columns
Columns for this table. |
protected java.util.HashMap |
columnsByName
Index to the columns, keyed by name. |
protected static boolean |
completeDdl
Whether we must produce complete DDL (when allowDDLOutput() && isOutputtingDdl()), or only for missing elements |
protected RDBMSAdapter |
dba
Database Adapter being used. |
protected static java.io.Writer |
ddlWriter
Writer to output any DDL. |
protected java.lang.Boolean |
existsInDatastore
Cache what we learned in a call to exists() |
protected org.jpox.store.mapped.DatastoreIdentifier |
identifier
Identifier name for the table. |
protected static org.jpox.util.Localiser |
LOCALISER
Localiser for messages. |
protected int |
state
State of the table |
protected RDBMSManager |
storeMgr
Manager for this table. |
| Fields inherited from interface org.jpox.store.rdbms.table.Table |
|---|
TABLE_STATE_INITIALIZED, TABLE_STATE_INITIALIZED_MODIFIED, TABLE_STATE_NEW, TABLE_STATE_PK_INITIALIZED, TABLE_STATE_VALIDATED, TABLE_TYPE_MISSING, TABLE_TYPE_TABLE, TABLE_TYPE_UNKNOWN, TABLE_TYPE_VIEW |
| Constructor Summary | |
|---|---|
AbstractTable(org.jpox.store.mapped.DatastoreIdentifier identifier,
RDBMSManager storeMgr)
Constructor taking the table name and the RDBMSManager managing this table. |
|
| Method Summary | |
|---|---|
protected void |
addColumnInternal(Column col)
Utility method to add a column to the internal representation |
org.jpox.store.mapped.DatastoreField |
addDatastoreField(java.lang.String storedJavaType,
org.jpox.store.mapped.DatastoreIdentifier name,
org.jpox.store.mapped.mapping.JavaTypeMapping mapping,
org.jpox.metadata.MetaData colmd)
Creates a new column in the table. |
protected boolean |
allowDDLOutput()
Determine whether we or our concrete class allow DDL to be written into a file instead of sending it to the DB. |
protected void |
assertIsInitialized()
|
protected void |
assertIsInitializedModified()
|
protected void |
assertIsPKInitialized()
|
protected void |
assertIsPKUninitialized()
|
protected void |
assertIsUninitialized()
|
protected void |
assertIsValidated()
|
boolean |
create(java.sql.Connection conn)
Method to create this table. |
void |
drop(java.sql.Connection conn)
Method to drop this table. |
boolean |
equals(java.lang.Object obj)
Equality operator. |
protected void |
executeDdlStatement(java.sql.Statement stmt,
java.lang.String stmtText)
Execute a single DDL SQL statement with appropriate logging. |
protected void |
executeDdlStatementList(java.util.List stmts,
java.sql.Connection conn)
Method to perform the required SQL statements. |
boolean |
exists(java.sql.Connection conn,
boolean auto_create)
Method to check the existence of the table/view, optionally auto creating it where required. |
java.lang.String |
getCatalogName()
Accessor for the Catalog Name. |
org.jpox.store.mapped.DatastoreField[] |
getDatastoreFieldsMetaData()
Accessor for the DatastoreFields infered from the java and metadata files. |
org.jpox.store.mapped.DatastoreIdentifier |
getDatastoreIdentifierFullyQualified()
Method that operates like toString except it returns a fully-qualified name that will always be fully-qualified even when the user hasnt specified the catalog/schema in PMF or MetaData. |
org.jpox.store.mapped.mapping.JavaTypeMapping |
getDiscriminatorMapping(boolean allowSuperclasses)
Accessor for the discriminator mapping specified . |
org.jpox.metadata.DiscriminatorMetaData |
getDiscriminatorMetaData()
Accessor for Discriminator MetaData |
org.jpox.store.mapped.DatastoreIdentifier |
getIdentifier()
Accessor for the SQL identifier (the table name). |
java.lang.String |
getSchemaName()
Accessor for the Schema Name. |
protected abstract java.util.List |
getSQLCreateStatements(java.util.Properties props)
Accessor for the SQL create statements. |
protected abstract java.util.List |
getSQLDropStatements()
Accessor for the SQL drop statements. |
org.jpox.store.mapped.MappedStoreManager |
getStoreManager()
Accessor for the Store Manager. |
org.jpox.store.mapped.mapping.JavaTypeMapping |
getVersionMapping(boolean allowSuperclasses)
Accessor for the version mapping specified. |
org.jpox.metadata.VersionMetaData |
getVersionMetaData()
Accessor for Version MetaData |
protected boolean |
hasColumnName(org.jpox.store.mapped.DatastoreIdentifier colName)
Utility to return if a column of this name exists. |
boolean |
hasDatastoreField(org.jpox.store.mapped.DatastoreIdentifier identifier)
Checks if there is a DatastoreField for the identifier |
int |
hashCode()
Accessor for the hascode of this table. |
static boolean |
isCompleteDdl()
|
boolean |
isInitialized()
Accessor for whether the table is initialised. |
boolean |
isInitializedModified()
Accessor for whether the table has been modified since initialisation. |
static boolean |
isOutputtingDDL()
Whether a writer is defined to output DDL |
boolean |
isPKInitialized()
Accessor for whether the primary key of the table is initialised. |
boolean |
isValidated()
Accessor for whether the table is validated. |
static void |
setCompleteDdl(boolean completeDdl)
Whether DDL should be generated regardless of whether table is missing or not |
static void |
setDdlWriter(java.io.Writer writer)
Set the file where any subsequent DDL SQL commands will be written to instead of issuing them to the database. |
protected boolean |
tableExistsInDatastore(java.sql.Connection conn)
Determine whether our table exists in the datastore (without modifying datastore). |
java.lang.String |
toString()
Method to return a string version of this table. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.jpox.store.rdbms.table.Table |
|---|
initialize, postInitialize, preInitialize, validate |
| Methods inherited from interface org.jpox.store.mapped.DatastoreContainerObject |
|---|
getFieldMapping, getIDMapping |
| Field Detail |
|---|
protected static final org.jpox.util.Localiser LOCALISER
protected final RDBMSManager storeMgr
protected final RDBMSAdapter dba
protected final org.jpox.store.mapped.DatastoreIdentifier identifier
protected int state
protected java.util.List columns
protected java.util.HashMap columnsByName
protected static java.io.Writer ddlWriter
protected static boolean completeDdl
protected java.lang.Boolean existsInDatastore
| Constructor Detail |
|---|
public AbstractTable(org.jpox.store.mapped.DatastoreIdentifier identifier,
RDBMSManager storeMgr)
identifier - Name of the tablestoreMgr - The RDBMS Manager| Method Detail |
|---|
public boolean isInitialized()
isInitialized in interface Tablepublic boolean isPKInitialized()
public boolean isValidated()
isValidated in interface Tablepublic boolean isInitializedModified()
isInitializedModified in interface Tablepublic org.jpox.store.mapped.MappedStoreManager getStoreManager()
getStoreManager in interface org.jpox.store.mapped.DatastoreObjectpublic java.lang.String getCatalogName()
getCatalogName in interface Tablepublic java.lang.String getSchemaName()
getSchemaName in interface Tablepublic org.jpox.store.mapped.DatastoreIdentifier getIdentifier()
getIdentifier in interface org.jpox.store.mapped.DatastoreObject
public org.jpox.store.mapped.DatastoreField addDatastoreField(java.lang.String storedJavaType,
org.jpox.store.mapped.DatastoreIdentifier name,
org.jpox.store.mapped.mapping.JavaTypeMapping mapping,
org.jpox.metadata.MetaData colmd)
addDatastoreField in interface org.jpox.store.mapped.DatastoreContainerObjectstoredJavaType - the java type of the datastore fieldname - the SQL identifier for the column to be addedmapping - the mapping for the column to be addedcolmd - ColumnMetaData for the column to be added to the table
DuplicateColumnNameException - if a column already exists with same name and not a supported situation.public boolean hasDatastoreField(org.jpox.store.mapped.DatastoreIdentifier identifier)
hasDatastoreField in interface org.jpox.store.mapped.DatastoreContainerObjectidentifier - the identifier of the DatastoreField
public org.jpox.store.mapped.DatastoreField[] getDatastoreFieldsMetaData()
getDatastoreFieldsMetaData in interface org.jpox.store.mapped.DatastoreContainerObject
public boolean create(java.sql.Connection conn)
throws java.sql.SQLException
create in interface Tableconn - Connection to the datastore.
java.sql.SQLException - Thrown if an error occurs creating the table.
public void drop(java.sql.Connection conn)
throws java.sql.SQLException
drop in interface Tableconn - Connection to the datastore.
java.sql.SQLException - Thrown if an error occurs dropping the table.
public boolean exists(java.sql.Connection conn,
boolean auto_create)
throws java.sql.SQLException
exists in interface Tableconn - The JDBC Connectionauto_create - Whether to auto create the table if not existing
java.sql.SQLException - Thrown when an error occurs in the JDBC callspublic final boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - The object to compare against
public final int hashCode()
hashCode in class java.lang.Objectpublic final java.lang.String toString()
toString in class java.lang.Objectpublic org.jpox.store.mapped.DatastoreIdentifier getDatastoreIdentifierFullyQualified()
protected void addColumnInternal(Column col)
col - The columnprotected boolean hasColumnName(org.jpox.store.mapped.DatastoreIdentifier colName)
colName - The column name
protected abstract java.util.List getSQLCreateStatements(java.util.Properties props)
props - Properties controlling the table creation
protected abstract java.util.List getSQLDropStatements()
protected void assertIsPKUninitialized()
protected void assertIsUninitialized()
protected void assertIsInitialized()
protected void assertIsInitializedModified()
protected void assertIsPKInitialized()
protected void assertIsValidated()
protected boolean allowDDLOutput()
public static boolean isOutputtingDDL()
public static void setDdlWriter(java.io.Writer writer)
writer - The writer to use for outputting DDL
protected void executeDdlStatementList(java.util.List stmts,
java.sql.Connection conn)
throws java.sql.SQLException
stmts - A List of statementsconn - The Connection to the datastore
java.sql.SQLException - Any exceptions thrown by the statements
protected void executeDdlStatement(java.sql.Statement stmt,
java.lang.String stmtText)
throws java.sql.SQLException
stmt - The JDBC Statement object to execute onstmtText - The actual SQL statement text
java.sql.SQLException - Thrown if an error occurssetDdlWriter(Writer)public org.jpox.metadata.DiscriminatorMetaData getDiscriminatorMetaData()
getDiscriminatorMetaData in interface org.jpox.store.mapped.DatastoreContainerObjectpublic org.jpox.store.mapped.mapping.JavaTypeMapping getDiscriminatorMapping(boolean allowSuperclasses)
getDiscriminatorMapping in interface org.jpox.store.mapped.DatastoreContainerObjectpublic org.jpox.metadata.VersionMetaData getVersionMetaData()
getVersionMetaData in interface org.jpox.store.mapped.DatastoreContainerObjectpublic org.jpox.store.mapped.mapping.JavaTypeMapping getVersionMapping(boolean allowSuperclasses)
getVersionMapping in interface org.jpox.store.mapped.DatastoreContainerObject
protected boolean tableExistsInDatastore(java.sql.Connection conn)
throws java.sql.SQLException
conn - The Connection
java.sql.SQLException - Thrown if an error occurspublic static boolean isCompleteDdl()
public static void setCompleteDdl(boolean completeDdl)
completeDdl -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||