public abstract class AbstractTable extends Object implements Table
Modifier and Type | Field and Description |
---|---|
protected List<org.datanucleus.store.schema.table.Column> |
columns
Columns for this table.
|
protected Map<DatastoreIdentifier,Column> |
columnsByIdentifier
Index to the columns, keyed by name identifier.
|
protected DatastoreAdapter |
dba
Database Adapter being used.
|
protected Boolean |
existsInDatastore
Cache what we learned in a call to exists()
|
protected DatastoreIdentifier |
identifier
Identifier name for the table.
|
protected int |
state
State of the table
|
protected RDBMSStoreManager |
storeMgr
Manager for this table.
|
protected static int |
TABLE_STATE_INITIALIZED
Table object has been initialised.
|
protected static int |
TABLE_STATE_INITIALIZED_MODIFIED
Table object has been initialized but has had structural modifications since.
|
protected static int |
TABLE_STATE_NEW
Table object has just been created.
|
protected static int |
TABLE_STATE_PK_INITIALIZED
Table object is created and PK initialised.
|
protected static int |
TABLE_STATE_VALIDATED
Table object has been validated.
|
Constructor and Description |
---|
AbstractTable(DatastoreIdentifier identifier,
RDBMSStoreManager storeMgr)
Constructor taking the table name and the RDBMSManager managing this table.
|
Modifier and Type | Method and Description |
---|---|
Column |
addColumn(String storedJavaType,
DatastoreIdentifier name,
JavaTypeMapping mapping,
org.datanucleus.metadata.ColumnMetaData colmd)
Creates a new column in the table.
|
protected void |
addColumnInternal(Column col)
Utility method to add a column to the internal representation
|
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(Connection conn)
Method to create this table.
|
void |
drop(Connection conn)
Method to drop this table.
|
boolean |
equals(Object obj)
Equality operator.
|
protected void |
executeDdlStatement(Statement stmt,
String stmtText)
Execute a single DDL SQL statement with appropriate logging.
|
protected void |
executeDdlStatementList(List stmts,
Connection conn)
Method to perform the required SQL statements.
|
boolean |
exists(Connection conn,
boolean auto_create)
Method to check the existence of the table/view, optionally auto creating it
where required.
|
String |
getCatalogName()
Accessor for the Catalog Name.
|
org.datanucleus.metadata.AbstractClassMetaData |
getClassMetaData() |
Column |
getColumn(DatastoreIdentifier identifier)
Accessor for the Datastore field with the specified identifier.
|
org.datanucleus.store.schema.table.Column |
getColumnForName(String name) |
org.datanucleus.store.schema.table.Column |
getColumnForPosition(int pos) |
List<org.datanucleus.store.schema.table.Column> |
getColumns() |
org.datanucleus.store.schema.table.Column |
getDatastoreIdColumn() |
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.datanucleus.store.schema.table.Column |
getDiscriminatorColumn() |
JavaTypeMapping |
getDiscriminatorMapping(boolean allowSuperclasses)
Accessor for the discriminator mapping specified .
|
org.datanucleus.metadata.DiscriminatorMetaData |
getDiscriminatorMetaData()
Accessor for Discriminator MetaData
|
DatastoreIdentifier |
getIdentifier()
Accessor for the SQL identifier (the table name).
|
org.datanucleus.store.schema.table.MemberColumnMapping |
getMemberColumnMappingForEmbeddedMember(List<org.datanucleus.metadata.AbstractMemberMetaData> mmds) |
org.datanucleus.store.schema.table.MemberColumnMapping |
getMemberColumnMappingForMember(org.datanucleus.metadata.AbstractMemberMetaData mmd) |
Set<org.datanucleus.store.schema.table.MemberColumnMapping> |
getMemberColumnMappings() |
org.datanucleus.store.schema.table.Column |
getMultitenancyColumn() |
JavaTypeMapping |
getMultitenancyMapping()
Accessor for the multi-tenancy mapping (if any).
|
String |
getName() |
int |
getNumberOfColumns() |
String |
getSchemaName()
Accessor for the Schema Name.
|
protected abstract List |
getSQLCreateStatements(Properties props)
Accessor for the SQL create statements.
|
protected abstract List |
getSQLDropStatements()
Accessor for the SQL drop statements.
|
RDBMSStoreManager |
getStoreManager() |
org.datanucleus.store.schema.table.Column |
getVersionColumn() |
JavaTypeMapping |
getVersionMapping(boolean allowSuperclasses)
Accessor for the version mapping specified.
|
org.datanucleus.metadata.VersionMetaData |
getVersionMetaData()
Accessor for Version MetaData
|
boolean |
hasColumn(DatastoreIdentifier identifier)
Checks if there is a column for the identifier
|
protected boolean |
hasColumnName(DatastoreIdentifier colName)
Utility to return if a column of this name exists.
|
int |
hashCode()
Accessor for the hascode of this table.
|
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.
|
protected boolean |
tableExistsInDatastore(Connection conn)
Determine whether our table exists in the datastore (without modifying datastore).
|
String |
toString()
Method to return a string version of this table.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getIdMapping, getMemberMapping, initialize, postInitialize, preInitialize, validate
protected static final int TABLE_STATE_NEW
protected static final int TABLE_STATE_PK_INITIALIZED
protected static final int TABLE_STATE_INITIALIZED
protected static final int TABLE_STATE_INITIALIZED_MODIFIED
protected static final int TABLE_STATE_VALIDATED
protected final RDBMSStoreManager storeMgr
protected final DatastoreAdapter dba
protected final DatastoreIdentifier identifier
protected int state
protected List<org.datanucleus.store.schema.table.Column> columns
protected Map<DatastoreIdentifier,Column> columnsByIdentifier
protected Boolean existsInDatastore
public AbstractTable(DatastoreIdentifier identifier, RDBMSStoreManager storeMgr)
identifier
- Name of the tablestoreMgr
- The RDBMS Managerpublic boolean isInitialized()
public boolean isPKInitialized()
public boolean isValidated()
public boolean isInitializedModified()
public RDBMSStoreManager getStoreManager()
getStoreManager
in interface org.datanucleus.store.schema.table.Table
public String getName()
getName
in interface org.datanucleus.store.schema.table.Table
public String getCatalogName()
getCatalogName
in interface org.datanucleus.store.schema.table.Table
public String getSchemaName()
getSchemaName
in interface org.datanucleus.store.schema.table.Table
public DatastoreIdentifier getIdentifier()
public org.datanucleus.metadata.AbstractClassMetaData getClassMetaData()
getClassMetaData
in interface org.datanucleus.store.schema.table.Table
public int getNumberOfColumns()
getNumberOfColumns
in interface org.datanucleus.store.schema.table.Table
public List<org.datanucleus.store.schema.table.Column> getColumns()
getColumns
in interface org.datanucleus.store.schema.table.Table
public org.datanucleus.store.schema.table.Column getColumnForPosition(int pos)
getColumnForPosition
in interface org.datanucleus.store.schema.table.Table
public org.datanucleus.store.schema.table.Column getDatastoreIdColumn()
getDatastoreIdColumn
in interface org.datanucleus.store.schema.table.Table
public org.datanucleus.store.schema.table.Column getVersionColumn()
getVersionColumn
in interface org.datanucleus.store.schema.table.Table
public org.datanucleus.store.schema.table.Column getDiscriminatorColumn()
getDiscriminatorColumn
in interface org.datanucleus.store.schema.table.Table
public org.datanucleus.store.schema.table.Column getMultitenancyColumn()
getMultitenancyColumn
in interface org.datanucleus.store.schema.table.Table
public org.datanucleus.store.schema.table.Column getColumnForName(String name)
getColumnForName
in interface org.datanucleus.store.schema.table.Table
public org.datanucleus.store.schema.table.MemberColumnMapping getMemberColumnMappingForMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
getMemberColumnMappingForMember
in interface org.datanucleus.store.schema.table.Table
public org.datanucleus.store.schema.table.MemberColumnMapping getMemberColumnMappingForEmbeddedMember(List<org.datanucleus.metadata.AbstractMemberMetaData> mmds)
getMemberColumnMappingForEmbeddedMember
in interface org.datanucleus.store.schema.table.Table
public Set<org.datanucleus.store.schema.table.MemberColumnMapping> getMemberColumnMappings()
getMemberColumnMappings
in interface org.datanucleus.store.schema.table.Table
public org.datanucleus.metadata.DiscriminatorMetaData getDiscriminatorMetaData()
public JavaTypeMapping getDiscriminatorMapping(boolean allowSuperclasses)
allowSuperclasses
- Whether we should return just the mapping from this table
or whether we should return it when this table has none and the supertable haspublic JavaTypeMapping getMultitenancyMapping()
Table
public org.datanucleus.metadata.VersionMetaData getVersionMetaData()
public JavaTypeMapping getVersionMapping(boolean allowSuperclasses)
allowSuperclasses
- Whether we should return just the mapping from this table
or whether we should return it when this table has none and the supertable haspublic Column addColumn(String storedJavaType, DatastoreIdentifier name, JavaTypeMapping mapping, org.datanucleus.metadata.ColumnMetaData colmd)
storedJavaType
- 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 tableDuplicateColumnException
- if a column already exists with same name and not a supported situation.public boolean hasColumn(DatastoreIdentifier identifier)
identifier
- the identifier of the columnpublic Column getColumn(DatastoreIdentifier identifier)
identifier
- The name of the columnpublic boolean create(Connection conn) throws SQLException
conn
- Connection to the datastore.SQLException
- Thrown if an error occurs creating the table.public void drop(Connection conn) throws SQLException
conn
- Connection to the datastore.SQLException
- Thrown if an error occurs dropping the table.public boolean exists(Connection conn, boolean auto_create) throws SQLException
conn
- The JDBC Connectionauto_create
- Whether to auto create the table if not existingSQLException
- Thrown when an error occurs in the JDBC callspublic final boolean equals(Object obj)
public final int hashCode()
public final String toString()
public DatastoreIdentifier getDatastoreIdentifierFullyQualified()
protected void addColumnInternal(Column col)
col
- The columnprotected boolean hasColumnName(DatastoreIdentifier colName)
colName
- The column nameprotected abstract List getSQLCreateStatements(Properties props)
props
- Properties controlling the table creationprotected abstract List getSQLDropStatements()
protected void assertIsPKUninitialized()
protected void assertIsUninitialized()
protected void assertIsInitialized()
protected void assertIsInitializedModified()
protected void assertIsPKInitialized()
protected void assertIsValidated()
protected boolean allowDDLOutput()
protected void executeDdlStatementList(List stmts, Connection conn) throws SQLException
stmts
- A List of statementsconn
- The Connection to the datastoreSQLException
- Any exceptions thrown by the statementsprotected void executeDdlStatement(Statement stmt, String stmtText) throws SQLException
stmt
- The JDBC Statement object to execute onstmtText
- The actual SQL statement textSQLException
- Thrown if an error occursprotected boolean tableExistsInDatastore(Connection conn) throws SQLException
conn
- The ConnectionSQLException
- Thrown if an error occursCopyright © 2017. All rights reserved.