|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jpox.store.rdbms.table.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 RDBMSAdapter |
dba
Database Adapter being used. |
protected static java.io.FileWriter |
ddlDumpWriter
Writer to output any DDL. |
protected DatastoreIdentifier |
identifier
Identifier name for the table. |
protected static 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(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 |
DatastoreField |
addDatastoreField(java.lang.String storedJavaType,
DatastoreIdentifier name,
JavaTypeMapping mapping,
ExtendableMetaData colmd)
Creates a new column. |
protected boolean |
allowDdlDump()
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()
|
void |
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. |
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. |
JavaTypeMapping |
getDiscriminatorMapping()
Accessor for the discriminator mapping specified . |
DiscriminatorMetaData |
getDiscriminatorMetaData()
Accessor for Discriminator MetaData |
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. |
StoreManager |
getStoreManager()
Accessor for the Store Manager. |
JavaTypeMapping |
getVersionMapping()
Accessor for the version mapping specified. |
VersionMetaData |
getVersionMetaData()
Accessor for Version MetaData |
protected boolean |
hasColumnName(DatastoreIdentifier colName)
Utility to return if a column of this name exists. |
boolean |
hasDatastoreField(DatastoreIdentifier identifier)
Checks if there is a DatastoreField for the identifier |
int |
hashCode()
Accessor for the hascode of this table. |
static boolean |
isDumpingDdl()
Whether a writer is defined to dump DDL |
boolean |
isInitialized()
Accessor for whether the table is initialised. |
boolean |
isInitializedModified()
Accessor for whether the table has been modified since initialisation. |
boolean |
isPKInitialized()
Accessor for whether the primary key of the table is initialised. |
boolean |
isValidated()
Accessor for whether the table is validated. |
static void |
setDdlDumpWriter(java.io.FileWriter fileWriter)
Set the file where any subsequent DDL SQL commands will be written to instead of issuing them to the database. |
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.DatastoreContainerObject |
getFieldMapping, getIDMapping |
Field Detail |
protected static final Localiser LOCALISER
protected final RDBMSManager storeMgr
protected final RDBMSAdapter dba
protected final DatastoreIdentifier identifier
protected int state
protected java.util.List columns
protected java.util.HashMap columnsByName
protected static java.io.FileWriter ddlDumpWriter
Constructor Detail |
public AbstractTable(DatastoreIdentifier identifier, RDBMSManager storeMgr)
identifier
- Name of the tablestoreMgr
- The RDBMS ManagerMethod Detail |
public boolean isInitialized()
isInitialized
in interface Table
public boolean isPKInitialized()
public boolean isValidated()
isValidated
in interface Table
public boolean isInitializedModified()
isInitializedModified
in interface Table
public StoreManager getStoreManager()
getStoreManager
in interface DatastoreObject
public java.lang.String getCatalogName()
getCatalogName
in interface Table
public java.lang.String getSchemaName()
getSchemaName
in interface Table
public DatastoreIdentifier getIdentifier()
getIdentifier
in interface DatastoreObject
public DatastoreField addDatastoreField(java.lang.String storedJavaType, DatastoreIdentifier name, JavaTypeMapping mapping, ExtendableMetaData colmd)
addDatastoreField
in interface DatastoreContainerObject
storedJavaType
- the type of the field that this represents.name
- the SQL identifiermapping
- the mapping for this columncolmd
- the ExtendableMetadata (ColumnMetaData for RDBMS)
DuplicateColumnNameException
- if a column already exists with same namepublic boolean hasDatastoreField(DatastoreIdentifier identifier)
hasDatastoreField
in interface DatastoreContainerObject
identifier
- the identifier of the DatastoreField
public void create(java.sql.Connection conn) throws java.sql.SQLException
create
in interface Table
conn
- 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 Table
conn
- 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 Table
conn
- 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)
obj
- The object to compare against
public final int hashCode()
public final java.lang.String toString()
public DatastoreIdentifier getDatastoreIdentifierFullyQualified()
protected void addColumnInternal(Column col)
col
- The columnprotected boolean hasColumnName(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 allowDdlDump()
public static boolean isDumpingDdl()
public static void setDdlDumpWriter(java.io.FileWriter fileWriter)
fileWriter
- The File writer to use for outputting DDLprotected 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 statementsprotected 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 occurssetDdlDumpWriter(FileWriter)
public DiscriminatorMetaData getDiscriminatorMetaData()
getDiscriminatorMetaData
in interface DatastoreContainerObject
public JavaTypeMapping getDiscriminatorMapping()
getDiscriminatorMapping
in interface DatastoreContainerObject
public VersionMetaData getVersionMetaData()
getVersionMetaData
in interface DatastoreContainerObject
public JavaTypeMapping getVersionMapping()
getVersionMapping
in interface DatastoreContainerObject
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |