org.datanucleus.store.rdbms.schema
Class RDBMSSchemaHandler

java.lang.Object
  extended by org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler
All Implemented Interfaces:
org.datanucleus.store.schema.StoreSchemaHandler

public class RDBMSSchemaHandler
extends java.lang.Object
implements org.datanucleus.store.schema.StoreSchemaHandler

Handler for RDBMS schema information. Provides access to the following types of schema data


Field Summary
protected  long COLUMN_INFO_EXPIRATION_MS
          Time within which column info is valid (millisecs).
protected static org.datanucleus.util.Localiser LOCALISER
          Localiser for messages.
protected  java.util.Map<java.lang.String,org.datanucleus.store.schema.StoreSchemaData> schemaDataByName
          Map of schema data, keyed by its symbolic name where the data is cached.
protected  RDBMSManager storeMgr
           
 
Constructor Summary
RDBMSSchemaHandler(RDBMSManager storeMgr)
           
 
Method Summary
 void clear()
          Method to clear out any cached schema information.
 void createSchema(java.lang.Object connection, java.lang.String schemaName)
          Method to create the schema with the supplied name.
 void deleteSchema(java.lang.Object connection, java.lang.String schemaName)
          Method to delete the schema with the supplied name.
protected  RDBMSColumnInfo getRDBMSColumnInfoForColumn(java.sql.Connection conn, Table table, java.lang.String columnName)
          Convenience method to get the column info from the datastore for the column in the specified table.
protected  RDBMSSchemaInfo getRDBMSSchemaInfoForCatalogSchema(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema)
          Convenience method to retrieve schema information for all tables in the specified catalog/schema.
protected  RDBMSTableFKInfo getRDBMSTableFKInfoForTable(java.sql.Connection conn, java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName)
          Convenience method to get the ForeignKey info for the specified table from the datastore.
protected  RDBMSTableFKInfo getRDBMSTableFKInfoForTable(java.sql.Connection conn, Table table)
          Convenience method to get the ForeignKey info for the specified table from the datastore.
protected  RDBMSTableIndexInfo getRDBMSTableIndexInfoForTable(java.sql.Connection conn, java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName)
          Convenience method to get the index info for the catalog+schema+tableName in the datastore.
protected  RDBMSTableIndexInfo getRDBMSTableIndexInfoForTable(java.sql.Connection conn, Table table)
          Convenience method to get the index info for the specified table from the datastore.
protected  RDBMSTableInfo getRDBMSTableInfoForTable(java.sql.Connection conn, java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName)
          Convenience method to get the column info for the catalog+schema+tableName in the datastore.
protected  RDBMSTableInfo getRDBMSTableInfoForTable(java.sql.Connection conn, Table table)
          Convenience method to get the column info for the specified table from the datastore.
protected  RDBMSTablePKInfo getRDBMSTablePKInfoForTable(java.sql.Connection conn, java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName)
          Convenience method to get the PrimaryKey info for the specified table from the datastore.
protected  RDBMSTablePKInfo getRDBMSTablePKInfoForTable(java.sql.Connection conn, Table table)
          Convenience method to get the PrimaryKey info for the specified table from the datastore.
protected  RDBMSTypesInfo getRDBMSTypesInfo(java.sql.Connection conn)
          Convenience method to read and cache the types information for this datastore.
 org.datanucleus.store.schema.StoreSchemaData getSchemaData(java.lang.Object connection, java.lang.String name, java.lang.Object[] values)
          Accessor for schema data store under the provided name and defined by the specified values.
 org.datanucleus.store.StoreManager getStoreManager()
          Accessor for the StoreManager we handle the schema for.
 java.lang.String getTableType(java.sql.Connection conn, Table table)
          Returns the type of a database table/view in the datastore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final org.datanucleus.util.Localiser LOCALISER
Localiser for messages.


COLUMN_INFO_EXPIRATION_MS

protected final long COLUMN_INFO_EXPIRATION_MS
Time within which column info is valid (millisecs). Set to 5 mins.

See Also:
Constant Field Values

storeMgr

protected final RDBMSManager storeMgr

schemaDataByName

protected java.util.Map<java.lang.String,org.datanucleus.store.schema.StoreSchemaData> schemaDataByName
Map of schema data, keyed by its symbolic name where the data is cached. Can be "types", "tables" etc. The "tables" cached here are "known tables" and not just all tables for the catalog/schema.

Constructor Detail

RDBMSSchemaHandler

public RDBMSSchemaHandler(RDBMSManager storeMgr)
Method Detail

clear

public void clear()
Method to clear out any cached schema information.

Specified by:
clear in interface org.datanucleus.store.schema.StoreSchemaHandler

createSchema

public void createSchema(java.lang.Object connection,
                         java.lang.String schemaName)
Method to create the schema with the supplied name.

Specified by:
createSchema in interface org.datanucleus.store.schema.StoreSchemaHandler
Parameters:
connection - Connection to the datastore
schemaName - Name of the schema

deleteSchema

public void deleteSchema(java.lang.Object connection,
                         java.lang.String schemaName)
Method to delete the schema with the supplied name.

Specified by:
deleteSchema in interface org.datanucleus.store.schema.StoreSchemaHandler
Parameters:
connection - Connection to the datastore
schemaName - Name of the schema

getSchemaData

public org.datanucleus.store.schema.StoreSchemaData getSchemaData(java.lang.Object connection,
                                                                  java.lang.String name,
                                                                  java.lang.Object[] values)
Accessor for schema data store under the provided name and defined by the specified values. When there are no "values" the following are supported usages:- When there is only one "value" the following are supported usages:- When there are two "values" the following are supported usages:- When there are 3 "values" the following are supported usages:-

Specified by:
getSchemaData in interface org.datanucleus.store.schema.StoreSchemaHandler
Parameters:
connection - Connection to the datastore
name - Name of the schema component to return.
values - Value(s) to use as qualifier(s) for selecting the schema component
Returns:
Schema data definition for this name

getStoreManager

public org.datanucleus.store.StoreManager getStoreManager()
Accessor for the StoreManager we handle the schema for.

Specified by:
getStoreManager in interface org.datanucleus.store.schema.StoreSchemaHandler
Returns:
Store Manager.

getTableType

public java.lang.String getTableType(java.sql.Connection conn,
                                     Table table)
                              throws java.sql.SQLException
Returns the type of a database table/view in the datastore. Uses DatabaseMetaData.getTables() to extract this information.

Parameters:
conn - Connection to the database.
table - The table/view
Returns:
The table type (consistent with the return from DatabaseMetaData.getTables())
Throws:
org.datanucleus.exceptions.NucleusDataStoreException - if an error occurs obtaining the information
java.sql.SQLException

getRDBMSTypesInfo

protected RDBMSTypesInfo getRDBMSTypesInfo(java.sql.Connection conn)
Convenience method to read and cache the types information for this datastore.

Parameters:
conn - Connection to the datastore
Returns:
The RDBMSTypesInfo

getRDBMSTableFKInfoForTable

protected RDBMSTableFKInfo getRDBMSTableFKInfoForTable(java.sql.Connection conn,
                                                       Table table)
Convenience method to get the ForeignKey info for the specified table from the datastore.

Parameters:
conn - Connection to use
table - The table
Returns:
The foreign key info

getRDBMSTableFKInfoForTable

protected RDBMSTableFKInfo getRDBMSTableFKInfoForTable(java.sql.Connection conn,
                                                       java.lang.String catalogName,
                                                       java.lang.String schemaName,
                                                       java.lang.String tableName)
Convenience method to get the ForeignKey info for the specified table from the datastore.

Parameters:
conn - Connection to use
catalogName - Catalog
schemaName - Schema
tableName - Name of the table
Returns:
The foreign key info

getRDBMSTablePKInfoForTable

protected RDBMSTablePKInfo getRDBMSTablePKInfoForTable(java.sql.Connection conn,
                                                       Table table)
Convenience method to get the PrimaryKey info for the specified table from the datastore.

Parameters:
conn - Connection to use
table - The table
Returns:
The primary key info

getRDBMSTablePKInfoForTable

protected RDBMSTablePKInfo getRDBMSTablePKInfoForTable(java.sql.Connection conn,
                                                       java.lang.String catalogName,
                                                       java.lang.String schemaName,
                                                       java.lang.String tableName)
Convenience method to get the PrimaryKey info for the specified table from the datastore.

Parameters:
conn - Connection to use
catalogName - Catalog
schemaName - Schema
tableName - Name of the table
Returns:
The primary key info

getRDBMSTableIndexInfoForTable

protected RDBMSTableIndexInfo getRDBMSTableIndexInfoForTable(java.sql.Connection conn,
                                                             Table table)
Convenience method to get the index info for the specified table from the datastore. Returns ALL indexes regardless of whether unique or not.

Parameters:
conn - Connection to use
table - The table
Returns:
The index info

getRDBMSTableIndexInfoForTable

protected RDBMSTableIndexInfo getRDBMSTableIndexInfoForTable(java.sql.Connection conn,
                                                             java.lang.String catalogName,
                                                             java.lang.String schemaName,
                                                             java.lang.String tableName)
Convenience method to get the index info for the catalog+schema+tableName in the datastore. Returns ALL indexes regardless of whether unique or not.

Parameters:
conn - Connection to use
catalogName - Catalog
schemaName - Schema
tableName - Name of the table
Returns:
The index info

getRDBMSSchemaInfoForCatalogSchema

protected RDBMSSchemaInfo getRDBMSSchemaInfoForCatalogSchema(java.sql.Connection conn,
                                                             java.lang.String catalog,
                                                             java.lang.String schema)
Convenience method to retrieve schema information for all tables in the specified catalog/schema.

Parameters:
conn - Connection
catalog - Catalog
schema - Schema
Returns:
Schema information

getRDBMSTableInfoForTable

protected RDBMSTableInfo getRDBMSTableInfoForTable(java.sql.Connection conn,
                                                   Table table)
Convenience method to get the column info for the specified table from the datastore.

Parameters:
conn - Connection to use
table - The table
Returns:
The table info containing the columns

getRDBMSTableInfoForTable

protected RDBMSTableInfo getRDBMSTableInfoForTable(java.sql.Connection conn,
                                                   java.lang.String catalogName,
                                                   java.lang.String schemaName,
                                                   java.lang.String tableName)
Convenience method to get the column info for the catalog+schema+tableName in the datastore.

Parameters:
conn - Connection to use
catalogName - Catalog
schemaName - Schema
tableName - Name of the table
Returns:
The table info containing the columns

getRDBMSColumnInfoForColumn

protected RDBMSColumnInfo getRDBMSColumnInfoForColumn(java.sql.Connection conn,
                                                      Table table,
                                                      java.lang.String columnName)
Convenience method to get the column info from the datastore for the column in the specified table.

Parameters:
conn - Connection to use
table - The table
columnName - Name of the column
Returns:
The column info for the table+column


Copyright © 2009. All Rights Reserved.