Class SchemaTable
- java.lang.Object
-
- org.datanucleus.store.rdbms.table.AbstractTable
-
- org.datanucleus.store.rdbms.table.TableImpl
-
- org.datanucleus.store.rdbms.autostart.SchemaTable
-
- All Implemented Interfaces:
Table
,org.datanucleus.store.schema.table.Table
public class SchemaTable extends TableImpl
Class defining DataNucleus schema definition tables. Represents a table in the datastore storing the class and table mappings. This table is used when restarting a DataNucleus system so that it is 'aware' of what classes were supported the previous time this datastore was used. It uses this information to pre-populate the RDBMSManager with the classes stored in this table. The table names are not used as such, other than as a record of what table a class maps to - because it goes off and finds the MetaData for the class which, with the DataNucleus naming scheme, defines the table name anyway.
-
-
Field Summary
Fields Modifier and Type Field Description private JavaTypeMapping
classMapping
private java.lang.String
deleteAllStmt
private java.lang.String
deleteStmt
private java.lang.String
fetchAllStmt
private java.lang.String
fetchStmt
private java.lang.String
insertStmt
private JavaTypeMapping
interfaceNameMapping
private JavaTypeMapping
ownerMapping
private JavaTypeMapping
tableMapping
private JavaTypeMapping
typeMapping
private JavaTypeMapping
versionMapping
-
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractTable
columns, columnsByIdentifier, dba, existsInDatastore, identifier, state, storeMgr, TABLE_STATE_INITIALIZED, TABLE_STATE_INITIALIZED_MODIFIED, TABLE_STATE_NEW, TABLE_STATE_PK_INITIALIZED, TABLE_STATE_VALIDATED
-
-
Constructor Summary
Constructors Constructor Description SchemaTable(RDBMSStoreManager storeMgr, java.lang.String tableName)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClass(RDBMSStoreData data, org.datanucleus.store.connection.ManagedConnection conn)
Method to insert a row in the SchemaTable.void
deleteAllClasses(org.datanucleus.store.connection.ManagedConnection conn)
Method to delete all classes from the SchemaTable.void
deleteClass(java.lang.String class_name, org.datanucleus.store.connection.ManagedConnection conn)
Method to delete a class from the SchemaTable.java.util.Set<org.datanucleus.store.StoreData>
getAllClasses(org.datanucleus.store.connection.ManagedConnection conn)
Accessor for the classes already supported by this Schema Table.JavaTypeMapping
getIdMapping()
Accessor for a mapping for the ID (persistable) for this table.JavaTypeMapping
getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor the for the mapping for a field/property stored in this table.private boolean
hasClass(org.datanucleus.store.StoreData data, org.datanucleus.store.connection.ManagedConnection conn)
Method to verify the a class is already stored in the table.void
initialize(org.datanucleus.ClassLoaderResolver clr)
Method to initialise the table.private boolean
tableExists(java.sql.Connection conn)
Convenience existence checker.-
Methods inherited from class org.datanucleus.store.rdbms.table.TableImpl
createConstraints, dropConstraints, getExpectedCandidateKeys, getExpectedForeignKeys, getExpectedIndices, getPrimaryKey, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, logMapping, validate, validateColumns, validateConstraints, validatePrimaryKey
-
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractTable
addColumn, addColumnInternal, allowDDLOutput, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getClassMetaData, getColumn, getColumnForName, getColumnForPosition, getColumns, getDatastoreIdentifierFullyQualified, getDiscriminatorMetaData, getIdentifier, getMemberColumnMappingForEmbeddedMember, getMemberColumnMappingForMember, getMemberColumnMappings, getName, getNumberOfColumns, getSchemaName, getStoreManager, getSurrogateColumn, getSurrogateMapping, getVersionMetaData, hasColumn, hasColumnName, hashCode, isInitialized, isInitializedModified, isPKInitialized, isValidated, postInitialize, preInitialize, tableExistsInDatastore, toString
-
-
-
-
Field Detail
-
classMapping
private JavaTypeMapping classMapping
-
tableMapping
private JavaTypeMapping tableMapping
-
typeMapping
private JavaTypeMapping typeMapping
-
ownerMapping
private JavaTypeMapping ownerMapping
-
versionMapping
private JavaTypeMapping versionMapping
-
interfaceNameMapping
private JavaTypeMapping interfaceNameMapping
-
insertStmt
private java.lang.String insertStmt
-
deleteStmt
private java.lang.String deleteStmt
-
deleteAllStmt
private java.lang.String deleteAllStmt
-
fetchAllStmt
private java.lang.String fetchAllStmt
-
fetchStmt
private java.lang.String fetchStmt
-
-
Constructor Detail
-
SchemaTable
public SchemaTable(RDBMSStoreManager storeMgr, java.lang.String tableName)
Constructor.- Parameters:
storeMgr
- The RDBMSManager for this datastoretableName
- Name of the starter table (optional, uses NUCLEUS_TABLES when this is null)
-
-
Method Detail
-
initialize
public void initialize(org.datanucleus.ClassLoaderResolver clr)
Method to initialise the table.- Parameters:
clr
- The ClassLoaderResolver
-
getIdMapping
public JavaTypeMapping getIdMapping()
Accessor for a mapping for the ID (persistable) for this table.- Returns:
- The (persistable) ID mapping.
-
getAllClasses
public java.util.Set<org.datanucleus.store.StoreData> getAllClasses(org.datanucleus.store.connection.ManagedConnection conn) throws java.sql.SQLException
Accessor for the classes already supported by this Schema Table.- Parameters:
conn
- Connection for this datastore.- Returns:
- The HashSet of class names (StoreData)
- Throws:
java.sql.SQLException
- Thrown when an error occurs in the process.
-
addClass
public void addClass(RDBMSStoreData data, org.datanucleus.store.connection.ManagedConnection conn) throws java.sql.SQLException
Method to insert a row in the SchemaTable. This is called when DataNucleus is now supporting a new class (and hence DB table).- Parameters:
data
- Data for the classconn
- Connection to the datastore- Throws:
java.sql.SQLException
- Thrown when an error occurs inserting the schema.
-
hasClass
private boolean hasClass(org.datanucleus.store.StoreData data, org.datanucleus.store.connection.ManagedConnection conn) throws java.sql.SQLException
Method to verify the a class is already stored in the table.- Parameters:
data
- Data for the classconn
- Connection to the datastore- Returns:
- if the SchemaTable already has the class
- Throws:
java.sql.SQLException
- Thrown when an error occurs inserting the schema.
-
deleteClass
public void deleteClass(java.lang.String class_name, org.datanucleus.store.connection.ManagedConnection conn) throws java.sql.SQLException
Method to delete a class from the SchemaTable. This is called when DataNucleus is required to clean out support for a particular class.- Parameters:
class_name
- Name of class to deleteconn
- Connection to the datastore- Throws:
java.sql.SQLException
- Thrown when an error occurs deleting the schema.
-
deleteAllClasses
public void deleteAllClasses(org.datanucleus.store.connection.ManagedConnection conn) throws java.sql.SQLException
Method to delete all classes from the SchemaTable. This is called when DataNucleus is required to clean out its supported classes (and hence DB table).- Parameters:
conn
- Connection to the datastore- Throws:
java.sql.SQLException
- Thrown when an error occurs deleting the schema.
-
tableExists
private boolean tableExists(java.sql.Connection conn) throws java.sql.SQLException
Convenience existence checker. This shouldn't be needed since exists already does this!- Parameters:
conn
- Connection to use- Returns:
- Whether it has been created
- Throws:
java.sql.SQLException
-
getMemberMapping
public JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor the for the mapping for a field/property stored in this table.- Parameters:
mmd
- MetaData for the field whose mapping we want- Returns:
- The mapping
-
-