org.datanucleus.store.rdbms
Class RDBMSManager

java.lang.Object
  extended by org.datanucleus.store.AbstractStoreManager
      extended by org.datanucleus.store.mapped.MappedStoreManager
          extended by org.datanucleus.store.rdbms.RDBMSManager
All Implemented Interfaces:
org.datanucleus.store.StoreManager

public class RDBMSManager
extends org.datanucleus.store.mapped.MappedStoreManager

StoreManager for RDBMS datastores. Provided by the "store-manager" extension key "rdbms" and accepts datastore URLs valid for JDBC.

The RDBMS manager's responsibilities extend those for StoreManager to add :

TODO Change RDBMSManager to share schema information (DatabaseMetaData) with other RDBMSManager.


Field Summary
protected  SQLExpressionFactory expressionFactory
          Factory for expressions using the generic query SQL mechanism.
protected static org.datanucleus.util.Localiser LOCALISER_RDBMS
          Localiser for messages.
 
Fields inherited from class org.datanucleus.store.mapped.MappedStoreManager
autoCreateColumns, autoCreateConstraints, autoCreateTables, autoCreateWarnOnError, datastoreContainerByIdentifier, dba, identifierFactory, insertedDatastoreClassByStateManager, mappedTypeMgr, mappingManager, validateColumns, validateConstraints, validateTables
 
Fields inherited from class org.datanucleus.store.AbstractStoreManager
autoStartMechanism, fixedDatastore, LOCALISER, nontxConnectionFactoryName, omfContext, persistenceHandler, readOnlyDatastore, readOnlyDatastoreAction, schemaHandler, starter, starterInitialised, storeDataMgr, storeManagerKey, storeManagerRuntime, txConnectionFactoryName, valueGenerationMgr
 
Constructor Summary
RDBMSManager(org.datanucleus.ClassLoaderResolver clr, org.datanucleus.OMFContext omfContext)
          Constructs a new RDBMSManager.
 
Method Summary
 void addClasses(java.lang.String[] classNames, org.datanucleus.ClassLoaderResolver clr)
          Method to add several (PersistenceCapable) classes to the store manager's set of supported classes.
 void addClasses(java.lang.String[] classNames, org.datanucleus.ClassLoaderResolver clr, java.io.Writer writer, boolean completeDdl)
          Method to add several (PersistenceCapable) classes to the store manager's set of supported classes.
 void addWrittenDdlStatement(java.lang.String stmt)
          When we are in SchemaTool DDL mode, add a new DDL statement.
 boolean allowsBatching()
          Convenience method to return if the datastore supports batching and the user wants batching.
 void close()
          Release of resources
 java.lang.String getCatalogName()
          Accessor for the (default) RDBMS catalog name.
 java.lang.String getClassNameForObjectID(java.lang.Object id, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.ObjectManager om)
          Returns the class corresponding to the given object JDO ID.
 RDBMSColumnInfo getColumnInfoForColumnName(Table table, java.sql.Connection conn, org.datanucleus.store.mapped.DatastoreIdentifier column)
          Returns the column info for a column name.
 java.util.List getColumnInfoForTable(Table table, java.sql.Connection conn)
          Returns the column info for a database table.
 boolean getCompleteDDL()
          Accessor for whether we should generate complete DDL when in that mode.
 ConnectionProvider getConnectionProvider()
          Accessor to the ConnectionProvider
 java.util.Date getDatastoreDate()
          Get the date/time of the datastore.
 java.io.Writer getDdlWriter()
          Accessor for the writer for DDL (if set).
 org.datanucleus.store.Extent getExtent(org.datanucleus.ObjectManager om, java.lang.Class c, boolean subclasses)
          Accessor for an Extent for a class, and its subclasses.
 org.datanucleus.store.mapped.FetchStatement getFetchStatement(org.datanucleus.store.mapped.DatastoreContainerObject table)
          Method to create a new fetch statement for the passed table.
 org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForResultProcessing(org.datanucleus.StateManager sm, java.lang.Object resultSet, org.datanucleus.store.mapped.StatementClassMapping resultMappings)
          Method to return a FieldManager for extracting information from the supplied results.
 org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForStatementGeneration(org.datanucleus.StateManager sm, java.lang.Object stmt, org.datanucleus.store.mapped.StatementClassMapping stmtMappings, boolean checkNonNullable)
          Method to return a FieldManager for populating information in statements.
 java.util.Collection getManagedTables(java.lang.String catalog, java.lang.String schema)
          Convenience accessor of the Table objects managed in this datastore at this point.
 org.datanucleus.store.NucleusConnection getNucleusConnection(org.datanucleus.ObjectManager om)
          Method to return a NucleusConnection for the ObjectManager.
 org.datanucleus.store.NucleusSequence getNucleusSequence(org.datanucleus.ObjectManager om, org.datanucleus.metadata.SequenceMetaData seqmd)
          Method to return a datastore sequence for this datastore matching the passed sequence MetaData.
protected  java.util.Properties getPropertiesForGenerator(org.datanucleus.metadata.AbstractClassMetaData cmd, int absoluteFieldNumber, org.datanucleus.ObjectManager om, org.datanucleus.metadata.SequenceMetaData seqmd, org.datanucleus.metadata.TableGeneratorMetaData tablegenmd)
          Method to return the properties to pass to the generator for the specified field.
 java.lang.Object getResultValueAtPosition(java.lang.Object resultSet, org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping, int position)
          Method to return the value from the results for the mapping at the specified position.
 org.datanucleus.util.MultiMap getSchemaCallbacks()
           
 java.lang.String getSchemaName()
          Accessor for the (default) RDBMS schema name.
 SQLController getSQLController()
          Accessor for the SQL controller.
 SQLExpressionFactory getSQLExpressionFactory()
          Accessor for the SQL expression factory to use when generating SQL statements.
 SQLTypeInfo getSQLTypeInfoForJDBCType(int jdbcType)
          Accessor for the (default) SQL type info for the specified JDBC type
protected  java.lang.String getStrategyForNative(java.lang.String sequence)
          Method defining which value-strategy to use when the user specifies "native".
protected  java.lang.Object getStrategyValueForGenerator(org.datanucleus.store.valuegenerator.ValueGenerator generator, org.datanucleus.ObjectManager om)
          Accessor for the next value from the specified generator.
 java.util.Collection getSupportedOptions()
          Accessor for the supported options in string form
 boolean hasWrittenDdlStatement(java.lang.String stmt)
          When we are in SchemaTool DDL mode, return if the supplied statement is already present.
protected  void initialiseIdentifierFactory(org.datanucleus.OMFContext omfContext)
          Method to create the IdentifierFactory to be used by this store.
 boolean insertValuesOnInsert(org.datanucleus.store.mapped.mapping.DatastoreMapping datastoreMapping)
          Accessor for whether this mapping requires values inserting on an INSERT.
 void invalidateColumnInfoForTable(Table table)
          Method to invalidate the cached column info for a table.
protected  void logConfiguration()
          Convenience method to log the configuration of this store manager.
protected  org.datanucleus.store.mapped.scostore.FKArrayStore newFKArrayStore(org.datanucleus.metadata.AbstractMemberMetaData ammd, org.datanucleus.ClassLoaderResolver clr)
           
protected  org.datanucleus.store.mapped.scostore.FKListStore newFKListStore(org.datanucleus.metadata.AbstractMemberMetaData ammd, org.datanucleus.ClassLoaderResolver clr)
           
protected  org.datanucleus.store.mapped.scostore.FKMapStore newFKMapStore(org.datanucleus.metadata.AbstractMemberMetaData ammd, org.datanucleus.ClassLoaderResolver clr)
           
protected  org.datanucleus.store.mapped.scostore.FKSetStore newFKSetStore(org.datanucleus.metadata.AbstractMemberMetaData ammd, org.datanucleus.ClassLoaderResolver clr)
           
protected  org.datanucleus.store.mapped.scostore.JoinArrayStore newJoinArrayStore(org.datanucleus.metadata.AbstractMemberMetaData amd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.mapped.DatastoreContainerObject table)
           
 org.datanucleus.store.mapped.DatastoreContainerObject newJoinDatastoreContainerObject(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr)
          Called by (container) Mapping objects to request the creation of a DatastoreObject (table).
protected  org.datanucleus.store.mapped.scostore.JoinListStore newJoinListStore(org.datanucleus.metadata.AbstractMemberMetaData amd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.mapped.DatastoreContainerObject table)
           
protected  org.datanucleus.store.mapped.scostore.JoinMapStore newJoinMapStore(org.datanucleus.metadata.AbstractMemberMetaData amd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.mapped.DatastoreContainerObject table)
           
protected  org.datanucleus.store.mapped.scostore.JoinSetStore newJoinSetStore(org.datanucleus.metadata.AbstractMemberMetaData amd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.mapped.DatastoreContainerObject table)
           
 org.datanucleus.store.query.ResultObjectFactory newResultObjectFactory(org.datanucleus.store.mapped.DatastoreClass table, org.datanucleus.metadata.AbstractClassMetaData acmd, org.datanucleus.store.mapped.StatementClassMapping mappingDefinition, boolean ignoreCache, boolean discriminator, org.datanucleus.FetchPlan fetchPlan, java.lang.Class persistentClass)
           
 void printInformation(java.lang.String category, java.io.PrintStream ps)
          Method to output particular information owned by this datastore.
 void removeAllClasses(org.datanucleus.ClassLoaderResolver clr)
          Utility to remove all classes that we are managing.
 void resolveIdentifierMacro(org.datanucleus.util.MacroString.IdentifierMacro im, org.datanucleus.ClassLoaderResolver clr)
          Resolves an identifier macro.
 void validateTable(TableImpl table, org.datanucleus.ClassLoaderResolver clr)
          Utility to validate the specified table.
 
Methods inherited from class org.datanucleus.store.mapped.MappedStoreManager
addDatastoreContainer, getBackingStoreForField, getClassesManagingTableForClass, getClassWithPrimaryKeyForClass, getDatastoreAdapter, getDatastoreClass, getDatastoreClass, getDatastoreContainerObject, getIdentifierFactory, getMappedTypeManager, getMappingManager, getStoreDataForDatastoreContainerObject, isObjectInserted, isObjectInserted, setObjectIsInsertedToLevel, supportsValueStrategy
 
Methods inherited from class org.datanucleus.store.AbstractStoreManager
addClass, assertReadOnlyForUpdateOfObject, clearAutoStarter, deregisterAllStoreData, getApiAdapter, getAutoStartMechanism, getConnection, getConnection, getConnection, getMetaDataManager, getOMFContext, getPersistenceHandler, getRuntimeManager, getSchemaHandler, getStoreManagerKey, getStrategyValue, getSubClassesForClass, getValueGenerationManager, initialiseAutoStart, isStrategyDatastoreAttributed, manageClassForIdentity, managesClass, newStoreData, notifyObjectIsOutdated, performVersionCheck, registerStoreData, supportsQueryLanguage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER_RDBMS

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


expressionFactory

protected SQLExpressionFactory expressionFactory
Factory for expressions using the generic query SQL mechanism.

Constructor Detail

RDBMSManager

public RDBMSManager(org.datanucleus.ClassLoaderResolver clr,
                    org.datanucleus.OMFContext omfContext)
Constructs a new RDBMSManager. On successful return the new RDBMSManager will have successfully connected to the database with the given credentials and determined the schema name, but will not have inspected the schema contents any further. The contents (tables, views, etc.) will be subsequently created and/or validated on-demand as the application accesses persistent classes.

To avoid creating unnecessary redundant RDBMSManagers, new RDBMSManagers should always be obtained from the StoreManagerFactory, rather than constructed directly.

Parameters:
clr - the ClassLoaderResolver
omfContext - The corresponding PersistenceManagerFactory. This factory's non-tx data source will be used to get database connections as needed to perform management functions.
Throws:
org.datanucleus.exceptions.NucleusDataStoreException - If the database could not be accessed or the name of the schema could not be determined.
Method Detail

getSchemaCallbacks

public org.datanucleus.util.MultiMap getSchemaCallbacks()

logConfiguration

protected void logConfiguration()
Convenience method to log the configuration of this store manager.

Overrides:
logConfiguration in class org.datanucleus.store.AbstractStoreManager

initialiseIdentifierFactory

protected void initialiseIdentifierFactory(org.datanucleus.OMFContext omfContext)
Method to create the IdentifierFactory to be used by this store. Relies on the datastore adapter existing before creation

Parameters:
omfContext - ObjectManagerFactory context

close

public void close()
Release of resources

Specified by:
close in interface org.datanucleus.store.StoreManager
Overrides:
close in class org.datanucleus.store.mapped.MappedStoreManager

getNucleusSequence

public org.datanucleus.store.NucleusSequence getNucleusSequence(org.datanucleus.ObjectManager om,
                                                                org.datanucleus.metadata.SequenceMetaData seqmd)
Method to return a datastore sequence for this datastore matching the passed sequence MetaData.

Specified by:
getNucleusSequence in interface org.datanucleus.store.StoreManager
Overrides:
getNucleusSequence in class org.datanucleus.store.AbstractStoreManager
Parameters:
om - The ObjectManager
seqmd - SequenceMetaData
Returns:
The Sequence

getNucleusConnection

public org.datanucleus.store.NucleusConnection getNucleusConnection(org.datanucleus.ObjectManager om)
Method to return a NucleusConnection for the ObjectManager.

Specified by:
getNucleusConnection in interface org.datanucleus.store.StoreManager
Specified by:
getNucleusConnection in class org.datanucleus.store.AbstractStoreManager
Parameters:
om - ObjectManager
Returns:
The NucleusConnection

getSQLController

public SQLController getSQLController()
Accessor for the SQL controller.

Returns:
The SQL controller

getSQLExpressionFactory

public SQLExpressionFactory getSQLExpressionFactory()
Accessor for the SQL expression factory to use when generating SQL statements.

Returns:
SQL expression factory

getCatalogName

public java.lang.String getCatalogName()
Accessor for the (default) RDBMS catalog name.

Returns:
The catalog name.

getSchemaName

public java.lang.String getSchemaName()
Accessor for the (default) RDBMS schema name.

Returns:
The schema name.

getConnectionProvider

public ConnectionProvider getConnectionProvider()
Accessor to the ConnectionProvider

Returns:
the ConnectionProvider

getDatastoreDate

public java.util.Date getDatastoreDate()
Get the date/time of the datastore.

Specified by:
getDatastoreDate in interface org.datanucleus.store.StoreManager
Specified by:
getDatastoreDate in class org.datanucleus.store.AbstractStoreManager
Returns:
Date/time of the datastore

addClasses

public void addClasses(java.lang.String[] classNames,
                       org.datanucleus.ClassLoaderResolver clr)
Method to add several (PersistenceCapable) classes to the store manager's set of supported classes. This will create any necessary database objects (tables, views, constraints, indexes etc). This will also cause the addition of any related classes.

Specified by:
addClasses in interface org.datanucleus.store.StoreManager
Overrides:
addClasses in class org.datanucleus.store.AbstractStoreManager
Parameters:
classNames - Name of the class(es) to be added.
clr - The ClassLoaderResolver

addClasses

public void addClasses(java.lang.String[] classNames,
                       org.datanucleus.ClassLoaderResolver clr,
                       java.io.Writer writer,
                       boolean completeDdl)
Method to add several (PersistenceCapable) classes to the store manager's set of supported classes. This will create any necessary database objects (tables, views, constraints, indexes etc). This will cause the addition of any related classes. This is used by SchemaTool and is specific to RDBMSManager

Parameters:
classNames - Name of the class(es) to be added.
clr - The ClassLoaderResolver
writer - Optional writer when you just want the DDL for persisting the specified classes
completeDdl - whether complete DDL will be created when writing DDL to a file, or only for missing elements

removeAllClasses

public void removeAllClasses(org.datanucleus.ClassLoaderResolver clr)
Utility to remove all classes that we are managing.

Specified by:
removeAllClasses in interface org.datanucleus.store.StoreManager
Overrides:
removeAllClasses in class org.datanucleus.store.AbstractStoreManager
Parameters:
clr - The ClassLoaderResolver

getDdlWriter

public java.io.Writer getDdlWriter()
Accessor for the writer for DDL (if set).

Returns:
DDL writer

getCompleteDDL

public boolean getCompleteDDL()
Accessor for whether we should generate complete DDL when in that mode. Otherwise will generate "upgrade DDL".

Returns:
Generate complete DDL ?

hasWrittenDdlStatement

public boolean hasWrittenDdlStatement(java.lang.String stmt)
When we are in SchemaTool DDL mode, return if the supplied statement is already present. This is used to eliminate duplicate statements from a bidirectional relation.

Parameters:
stmt - The statement
Returns:
Whether we have that statement already

addWrittenDdlStatement

public void addWrittenDdlStatement(java.lang.String stmt)
When we are in SchemaTool DDL mode, add a new DDL statement.

Parameters:
stmt - The statement

validateTable

public void validateTable(TableImpl table,
                          org.datanucleus.ClassLoaderResolver clr)
Utility to validate the specified table. This is useful where we have made an update to the columns in a table and want to apply the updates to the datastore.

Parameters:
clr - The ClassLoaderResolver

getFetchStatement

public org.datanucleus.store.mapped.FetchStatement getFetchStatement(org.datanucleus.store.mapped.DatastoreContainerObject table)
Method to create a new fetch statement for the passed table.

Specified by:
getFetchStatement in class org.datanucleus.store.mapped.MappedStoreManager
Parameters:
table - The table to fetch from
Returns:
The fetch statement TODO Remove this when we ditch FetchStatement

getClassNameForObjectID

public java.lang.String getClassNameForObjectID(java.lang.Object id,
                                                org.datanucleus.ClassLoaderResolver clr,
                                                org.datanucleus.ObjectManager om)
Returns the class corresponding to the given object JDO ID. If the object is an OID, return the PersistenceCapable class. If the object is a SCOID, return the SCO class. If the object is an AppID PK, return the PersistenceCapable class that the id relates to. If SingleFieldIdentity return the associated PC class. If the object id is an application id and the user supplies the "pm" argument then a check can be performed in the datastore where necessary.

Specified by:
getClassNameForObjectID in interface org.datanucleus.store.StoreManager
Overrides:
getClassNameForObjectID in class org.datanucleus.store.AbstractStoreManager
Parameters:
id - The JDO identity of some object.
clr - ClassLoader resolver
om - Object Manager (optional - to allow check in the datastore)
Returns:
For datastore identity, return the class of the corresponding object. For application identity, return the class of the corresponding object or null if object does not exist.
Throws:
java.lang.ClassCastException - If the type of ID is not recognized ( OIDor SCOID).

getFieldManagerForResultProcessing

public org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForResultProcessing(org.datanucleus.StateManager sm,
                                                                                          java.lang.Object resultSet,
                                                                                          org.datanucleus.store.mapped.StatementClassMapping resultMappings)
Method to return a FieldManager for extracting information from the supplied results.

Specified by:
getFieldManagerForResultProcessing in class org.datanucleus.store.mapped.MappedStoreManager
Parameters:
sm - StateManager for the object
resultSet - The results
resultMappings - Mappings for the results for this class
Returns:
FieldManager to use

getFieldManagerForStatementGeneration

public org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForStatementGeneration(org.datanucleus.StateManager sm,
                                                                                             java.lang.Object stmt,
                                                                                             org.datanucleus.store.mapped.StatementClassMapping stmtMappings,
                                                                                             boolean checkNonNullable)
Method to return a FieldManager for populating information in statements.

Specified by:
getFieldManagerForStatementGeneration in class org.datanucleus.store.mapped.MappedStoreManager
Parameters:
sm - The state manager for the object.
stmt - The Prepared Statement to set values on.
stmtMappings - the index of parameters/mappings
checkNonNullable - Whether to check for nullability
Returns:
The FieldManager to use

getResultValueAtPosition

public java.lang.Object getResultValueAtPosition(java.lang.Object resultSet,
                                                 org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping,
                                                 int position)
Method to return the value from the results for the mapping at the specified position.

Specified by:
getResultValueAtPosition in class org.datanucleus.store.mapped.MappedStoreManager
Parameters:
resultSet - The results
mapping - The mapping
position - The position in the results
Returns:
The value at that position
Throws:
org.datanucleus.exceptions.NucleusDataStoreException - if an error occurs accessing the results

getExtent

public org.datanucleus.store.Extent getExtent(org.datanucleus.ObjectManager om,
                                              java.lang.Class c,
                                              boolean subclasses)
Accessor for an Extent for a class, and its subclasses.

Specified by:
getExtent in interface org.datanucleus.store.StoreManager
Specified by:
getExtent in class org.datanucleus.store.AbstractStoreManager
Parameters:
om - The ObjectManager
c - The (candidate) class to use for the Extent
subclasses - Whether to include subclasses of 'c'
Returns:
The Extent
Throws:
org.datanucleus.store.exceptions.NoExtentException - if an extent is not managed for the specified class

getStrategyValueForGenerator

protected java.lang.Object getStrategyValueForGenerator(org.datanucleus.store.valuegenerator.ValueGenerator generator,
                                                        org.datanucleus.ObjectManager om)
Accessor for the next value from the specified generator. This implementation caters for datastore-specific generators and provides synchronisation on the connection to the datastore.

Overrides:
getStrategyValueForGenerator in class org.datanucleus.store.AbstractStoreManager
Parameters:
generator - The generator
Returns:
The next value.

getPropertiesForGenerator

protected java.util.Properties getPropertiesForGenerator(org.datanucleus.metadata.AbstractClassMetaData cmd,
                                                         int absoluteFieldNumber,
                                                         org.datanucleus.ObjectManager om,
                                                         org.datanucleus.metadata.SequenceMetaData seqmd,
                                                         org.datanucleus.metadata.TableGeneratorMetaData tablegenmd)
Method to return the properties to pass to the generator for the specified field.

Overrides:
getPropertiesForGenerator in class org.datanucleus.store.AbstractStoreManager
Parameters:
cmd - MetaData for the class
absoluteFieldNumber - Number of the field (-1 = datastore identity)
om - Object Manager
seqmd - Any sequence metadata
tablegenmd - Any table generator metadata
Returns:
The properties to use for this field

getStrategyForNative

protected java.lang.String getStrategyForNative(java.lang.String sequence)
Method defining which value-strategy to use when the user specifies "native".

Overrides:
getStrategyForNative in class org.datanucleus.store.AbstractStoreManager
Parameters:
sequence - Sequence name if specified
Returns:
Just returns "increment". Should be overridden by all store managers that have other behaviour.

getSQLTypeInfoForJDBCType

public SQLTypeInfo getSQLTypeInfoForJDBCType(int jdbcType)
                                      throws org.datanucleus.store.exceptions.UnsupportedDataTypeException
Accessor for the (default) SQL type info for the specified JDBC type

Parameters:
jdbcType - JDBC type
Returns:
(default) SQL type
Throws:
org.datanucleus.store.exceptions.UnsupportedDataTypeException - If the JDBC type is not found

getColumnInfoForColumnName

public RDBMSColumnInfo getColumnInfoForColumnName(Table table,
                                                  java.sql.Connection conn,
                                                  org.datanucleus.store.mapped.DatastoreIdentifier column)
                                           throws java.sql.SQLException
Returns the column info for a column name. This should be used instead of making direct calls to DatabaseMetaData.getColumns().

Where possible, this method loads and caches column info for more than just the table being requested, improving performance by reducing the overall number of calls made to DatabaseMetaData.getColumns() (each of which usually results in one or more database queries).

Parameters:
table - The table/view
conn - JDBC connection to the database.
column - the column
Returns:
The ColumnInfo objects describing the column.
Throws:
java.sql.SQLException

getColumnInfoForTable

public java.util.List getColumnInfoForTable(Table table,
                                            java.sql.Connection conn)
                                     throws java.sql.SQLException
Returns the column info for a database table. This should be used instead of making direct calls to DatabaseMetaData.getColumns().

Where possible, this method loads and caches column info for more than just the table being requested, improving performance by reducing the overall number of calls made to DatabaseMetaData.getColumns() (each of which usually results in one or more database queries).

Parameters:
table - The table/view
conn - JDBC connection to the database.
Returns:
A list of ColumnInfo objects describing the columns of the table. The list is in the same order as was supplied by getColumns(). If no column info is found for the given table, an empty list is returned.
Throws:
java.sql.SQLException

invalidateColumnInfoForTable

public void invalidateColumnInfoForTable(Table table)
Method to invalidate the cached column info for a table. This is called when we have just added columns to the table in the schema has the effect of a reload of the tables information the next time it is needed.

Parameters:
table - The table

getManagedTables

public java.util.Collection getManagedTables(java.lang.String catalog,
                                             java.lang.String schema)
Convenience accessor of the Table objects managed in this datastore at this point.

Parameters:
catalog - Name of the catalog to restrict the collection by
schema - Name of the schema to restrict the collection by
Returns:
Collection

resolveIdentifierMacro

public void resolveIdentifierMacro(org.datanucleus.util.MacroString.IdentifierMacro im,
                                   org.datanucleus.ClassLoaderResolver clr)
Resolves an identifier macro. The public fields className, fieldName , and subfieldName of the given macro are taken as inputs, and the public value field is set to the SQL identifier of the corresponding database table or column.

Parameters:
im - The macro to resolve.
clr - The ClassLoaderResolver

printInformation

public void printInformation(java.lang.String category,
                             java.io.PrintStream ps)
                      throws java.lang.Exception
Method to output particular information owned by this datastore. Supports "DATASTORE" and "SCHEMA" categories.

Specified by:
printInformation in interface org.datanucleus.store.StoreManager
Overrides:
printInformation in class org.datanucleus.store.AbstractStoreManager
Parameters:
category - Category of information
ps - PrintStream
Throws:
java.lang.Exception - Thrown if an error occurs in the output process

newJoinDatastoreContainerObject

public org.datanucleus.store.mapped.DatastoreContainerObject newJoinDatastoreContainerObject(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                                             org.datanucleus.ClassLoaderResolver clr)
Called by (container) Mapping objects to request the creation of a DatastoreObject (table). If the specified field doesn't require a join table then this returns null. If the join table already exists, then this returns it.

Specified by:
newJoinDatastoreContainerObject in class org.datanucleus.store.mapped.MappedStoreManager
Parameters:
mmd - The field metadata describing the field.
clr - The ClassLoaderResolver
Returns:
The container object (SetTable/ListTable/MapTable/ArrayTable)

getSupportedOptions

public java.util.Collection getSupportedOptions()
Accessor for the supported options in string form

Specified by:
getSupportedOptions in interface org.datanucleus.store.StoreManager
Overrides:
getSupportedOptions in class org.datanucleus.store.AbstractStoreManager

insertValuesOnInsert

public boolean insertValuesOnInsert(org.datanucleus.store.mapped.mapping.DatastoreMapping datastoreMapping)
Accessor for whether this mapping requires values inserting on an INSERT.

Specified by:
insertValuesOnInsert in class org.datanucleus.store.mapped.MappedStoreManager
Parameters:
datastoreMapping - The datastore mapping
Returns:
Whether values are to be inserted into this mapping on an INSERT

allowsBatching

public boolean allowsBatching()
Convenience method to return if the datastore supports batching and the user wants batching.

Specified by:
allowsBatching in class org.datanucleus.store.mapped.MappedStoreManager
Returns:
If batching of statements is permissible

newResultObjectFactory

public org.datanucleus.store.query.ResultObjectFactory newResultObjectFactory(org.datanucleus.store.mapped.DatastoreClass table,
                                                                              org.datanucleus.metadata.AbstractClassMetaData acmd,
                                                                              org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
                                                                              boolean ignoreCache,
                                                                              boolean discriminator,
                                                                              org.datanucleus.FetchPlan fetchPlan,
                                                                              java.lang.Class persistentClass)
Specified by:
newResultObjectFactory in class org.datanucleus.store.mapped.MappedStoreManager

newFKArrayStore

protected org.datanucleus.store.mapped.scostore.FKArrayStore newFKArrayStore(org.datanucleus.metadata.AbstractMemberMetaData ammd,
                                                                             org.datanucleus.ClassLoaderResolver clr)
Specified by:
newFKArrayStore in class org.datanucleus.store.mapped.MappedStoreManager

newFKListStore

protected org.datanucleus.store.mapped.scostore.FKListStore newFKListStore(org.datanucleus.metadata.AbstractMemberMetaData ammd,
                                                                           org.datanucleus.ClassLoaderResolver clr)
Specified by:
newFKListStore in class org.datanucleus.store.mapped.MappedStoreManager

newFKSetStore

protected org.datanucleus.store.mapped.scostore.FKSetStore newFKSetStore(org.datanucleus.metadata.AbstractMemberMetaData ammd,
                                                                         org.datanucleus.ClassLoaderResolver clr)
Specified by:
newFKSetStore in class org.datanucleus.store.mapped.MappedStoreManager

newFKMapStore

protected org.datanucleus.store.mapped.scostore.FKMapStore newFKMapStore(org.datanucleus.metadata.AbstractMemberMetaData ammd,
                                                                         org.datanucleus.ClassLoaderResolver clr)
Specified by:
newFKMapStore in class org.datanucleus.store.mapped.MappedStoreManager

newJoinArrayStore

protected org.datanucleus.store.mapped.scostore.JoinArrayStore newJoinArrayStore(org.datanucleus.metadata.AbstractMemberMetaData amd,
                                                                                 org.datanucleus.ClassLoaderResolver clr,
                                                                                 org.datanucleus.store.mapped.DatastoreContainerObject table)
Specified by:
newJoinArrayStore in class org.datanucleus.store.mapped.MappedStoreManager

newJoinMapStore

protected org.datanucleus.store.mapped.scostore.JoinMapStore newJoinMapStore(org.datanucleus.metadata.AbstractMemberMetaData amd,
                                                                             org.datanucleus.ClassLoaderResolver clr,
                                                                             org.datanucleus.store.mapped.DatastoreContainerObject table)
Specified by:
newJoinMapStore in class org.datanucleus.store.mapped.MappedStoreManager

newJoinListStore

protected org.datanucleus.store.mapped.scostore.JoinListStore newJoinListStore(org.datanucleus.metadata.AbstractMemberMetaData amd,
                                                                               org.datanucleus.ClassLoaderResolver clr,
                                                                               org.datanucleus.store.mapped.DatastoreContainerObject table)
Specified by:
newJoinListStore in class org.datanucleus.store.mapped.MappedStoreManager

newJoinSetStore

protected org.datanucleus.store.mapped.scostore.JoinSetStore newJoinSetStore(org.datanucleus.metadata.AbstractMemberMetaData amd,
                                                                             org.datanucleus.ClassLoaderResolver clr,
                                                                             org.datanucleus.store.mapped.DatastoreContainerObject table)
Specified by:
newJoinSetStore in class org.datanucleus.store.mapped.MappedStoreManager


Copyright © 2009. All Rights Reserved.