org.datanucleus.store.rdbms
Class RDBMSStoreManager

java.lang.Object
  extended by org.datanucleus.properties.PropertyStore
      extended by org.datanucleus.store.AbstractStoreManager
          extended by org.datanucleus.store.mapped.MappedStoreManager
              extended by org.datanucleus.store.rdbms.RDBMSStoreManager
All Implemented Interfaces:
org.datanucleus.store.BackedSCOStoreManager, org.datanucleus.store.schema.SchemaAwareStoreManager, org.datanucleus.store.StoreManager

public class RDBMSStoreManager
extends org.datanucleus.store.mapped.MappedStoreManager
implements org.datanucleus.store.schema.SchemaAwareStoreManager

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
catalogName, datastoreContainerByIdentifier, dba, identifierFactory, insertedDatastoreClassByStateManager, mappedTypeMgr, mappingManager, schemaLock, schemaName
 
Fields inherited from class org.datanucleus.store.AbstractStoreManager
autoCreateColumns, autoCreateConstraints, autoCreateTables, autoCreateWarnOnError, autoStartMechanism, connectionMgr, fixedDatastore, LOCALISER, namingFactory, nontxConnectionFactoryName, nucleusContext, persistenceHandler, readOnlyDatastore, schemaHandler, starter, starterInitialised, storeDataMgr, storeManagerKey, txConnectionFactoryName, validateColumns, validateConstraints, validateTables
 
Fields inherited from class org.datanucleus.properties.PropertyStore
properties
 
Constructor Summary
RDBMSStoreManager(org.datanucleus.ClassLoaderResolver clr, org.datanucleus.NucleusContext ctx, Map<String,Object> props)
          Constructs a new RDBMSManager.
 
Method Summary
 void addClasses(String[] classNames, org.datanucleus.ClassLoaderResolver clr)
          Method to add several persistable classes to the store manager's set of supported classes.
 void addSchemaCallback(String className, org.datanucleus.metadata.AbstractMemberMetaData mmd)
           
protected  void addSequenceForMetaData(org.datanucleus.metadata.MetaData md, String seq, org.datanucleus.ClassLoaderResolver clr, Set<String> sequencesGenerated, FileWriter ddlWriter)
           
protected  void addSequenceTableForMetaData(org.datanucleus.metadata.MetaData md, org.datanucleus.ClassLoaderResolver clr, Set<String> seqTablesGenerated)
           
 void addWrittenDdlStatement(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.
protected static Set<String> cleanInputClassNames(org.datanucleus.NucleusContext ctx, Set<String> inputClassNames)
          Method to generate a set of class names using the input list.
 void close()
          Release of resources
 void createSchema(Set<String> inputClassNames, Properties props)
           
protected  void createSchemaSequences(Set<String> classNames, org.datanucleus.ClassLoaderResolver clr, FileWriter ddlWriter)
           
 void deleteSchema(Set<String> inputClassNames, Properties props)
           
 Calendar getCalendarForDateTimezone()
          Accessor for the Calendar to be used in handling all timezone issues with the datastore.
 String getCatalogName()
          Accessor for the (default) RDBMS catalog name.
 String getClassNameForObjectID(Object id, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.ExecutionContext ec)
          Returns the class corresponding to the given object identity.
 RDBMSColumnInfo getColumnInfoForColumnName(Table table, Connection conn, org.datanucleus.store.mapped.DatastoreIdentifier column)
          Returns the column info for a column name.
 List getColumnInfoForTable(Table table, Connection conn)
          Returns the column info for a database table.
 boolean getCompleteDDL()
          Accessor for whether we should generate complete DDL when in that mode.
 Date getDatastoreDate()
          Get the date/time of the datastore.
 Writer getDdlWriter()
          Accessor for the writer for DDL (if set).
 org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForResultProcessing(org.datanucleus.store.ExecutionContext ec, Object resultSet, org.datanucleus.store.mapped.StatementClassMapping resultMappings, org.datanucleus.metadata.AbstractClassMetaData cmd)
           
 org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForResultProcessing(org.datanucleus.store.ObjectProvider sm, Object resultSet, org.datanucleus.store.mapped.StatementClassMapping resultMappings)
           
 org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForStatementGeneration(org.datanucleus.store.ObjectProvider sm, Object stmt, org.datanucleus.store.mapped.StatementClassMapping stmtMappings, boolean checkNonNullable)
          Method to return a FieldManager for populating information in statements.
 Collection getManagedTables(String catalog, String schema)
          Convenience accessor of the Table objects managed in this datastore at this point.
 org.datanucleus.store.NucleusConnection getNucleusConnection(org.datanucleus.store.ExecutionContext ec)
          Method to return a NucleusConnection for the ObjectManager.
 org.datanucleus.store.NucleusSequence getNucleusSequence(org.datanucleus.store.ExecutionContext ec, org.datanucleus.metadata.SequenceMetaData seqmd)
          Method to return a datastore sequence for this datastore matching the passed sequence MetaData.
protected  Properties getPropertiesForGenerator(org.datanucleus.metadata.AbstractClassMetaData cmd, int absoluteFieldNumber, org.datanucleus.store.ExecutionContext ec, org.datanucleus.metadata.SequenceMetaData seqmd, org.datanucleus.metadata.TableGeneratorMetaData tablegenmd)
          Method to return the properties to pass to the generator for the specified field.
 String getQueryCacheKey()
           
 Object getResultValueAtPosition(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()
           
 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 SQL type info for the specified JDBC type
 SQLTypeInfo getSQLTypeInfoForJDBCType(int jdbcType, String sqlType)
          Accessor for the SQL type info for the specified JDBC type.
protected  String getStrategyForNative(org.datanucleus.metadata.AbstractClassMetaData cmd, int absFieldNumber)
          Method defining which value-strategy to use when the user specifies "native".
protected  Object getStrategyValueForGenerator(org.datanucleus.store.valuegenerator.ValueGenerator generator, org.datanucleus.store.ExecutionContext ec)
          Accessor for the next value from the specified generator.
 Collection getSupportedOptions()
          Accessor for the supported options in string form
 boolean hasWrittenDdlStatement(String stmt)
          When we are in SchemaTool DDL mode, return if the supplied statement is already present.
 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.scostore.ArrayStore newFKArrayStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr)
           
protected  org.datanucleus.store.scostore.ListStore newFKListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr)
           
protected  org.datanucleus.store.scostore.MapStore newFKMapStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr)
           
protected  org.datanucleus.store.scostore.SetStore newFKSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr)
           
protected  org.datanucleus.store.scostore.ArrayStore newJoinArrayStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, 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.scostore.ListStore newJoinListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.mapped.DatastoreContainerObject table)
           
protected  org.datanucleus.store.scostore.MapStore newJoinMapStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.mapped.DatastoreContainerObject table)
           
protected  org.datanucleus.store.scostore.SetStore newJoinSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.mapped.DatastoreContainerObject table)
           
protected  org.datanucleus.store.scostore.PersistableRelationStore newPersistableRelationStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.store.mapped.DatastoreContainerObject table)
           
 org.datanucleus.store.query.ResultObjectFactory newResultObjectFactory(org.datanucleus.metadata.AbstractClassMetaData acmd, org.datanucleus.store.mapped.StatementClassMapping mappingDefinition, boolean ignoreCache, org.datanucleus.FetchPlan fetchPlan, Class persistentClass)
           
 void printInformation(String category, 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.
 boolean useBackedSCOWrapperForMember(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.store.ExecutionContext ec)
           
 boolean usesBackedSCOWrappers()
           
 void validateSchema(Set<String> inputClassNames, Properties props)
           
 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, getDefaultIdentifierCase, getIdentifierFactory, getMappedTypeManager, getMappingManager, getStoreDataForDatastoreContainerObject, initialiseIdentifierFactory, isObjectInserted, isObjectInserted, setObjectIsInsertedToLevel, supportsValueStrategy
 
Methods inherited from class org.datanucleus.store.AbstractStoreManager
addClass, assertReadOnlyForUpdateOfObject, clearAutoStarter, deregisterAllStoreData, getApiAdapter, getBooleanObjectProperty, getBooleanProperty, getBooleanProperty, getConnection, getConnection, getConnection, getConnectionDriverName, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionManager, getConnectionPassword, getConnectionURL, getConnectionUserName, getExtent, getIntProperty, getMetaDataManager, getNamingFactory, getNucleusContext, getPersistenceHandler, getProperty, getQueryManager, getSchemaHandler, getStoreManagerKey, getStrategyValue, getStringProperty, getSubClassesForClass, getValueGenerationManager, initialiseAutoStart, isAutoCreateColumns, isAutoCreateConstraints, isAutoCreateTables, isStrategyDatastoreAttributed, isValidateColumns, isValidateConstraints, isValidateTables, manageClassForIdentity, managesClass, newStoreData, registerConnectionFactory, registerConnectionMgr, registerStoreData, supportsQueryLanguage, transactionCommitted, transactionRolledBack, transactionStarted
 
Methods inherited from class org.datanucleus.properties.PropertyStore
hasProperty, hasPropertyNotNull, setPropertyInternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.datanucleus.store.StoreManager
hasProperty
 

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

RDBMSStoreManager

public RDBMSStoreManager(org.datanucleus.ClassLoaderResolver clr,
                         org.datanucleus.NucleusContext ctx,
                         Map<String,Object> props)
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.

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

getQueryCacheKey

public String getQueryCacheKey()
Specified by:
getQueryCacheKey in interface org.datanucleus.store.StoreManager
Overrides:
getQueryCacheKey in class org.datanucleus.store.AbstractStoreManager

getSchemaCallbacks

public org.datanucleus.util.MultiMap getSchemaCallbacks()

addSchemaCallback

public void addSchemaCallback(String className,
                              org.datanucleus.metadata.AbstractMemberMetaData mmd)

logConfiguration

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

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

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.store.ExecutionContext ec,
                                                                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:
ec - execution context
seqmd - SequenceMetaData
Returns:
The Sequence

getNucleusConnection

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

Specified by:
getNucleusConnection in interface org.datanucleus.store.StoreManager
Overrides:
getNucleusConnection in class org.datanucleus.store.AbstractStoreManager
Parameters:
ec - execution context
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 String getCatalogName()
Accessor for the (default) RDBMS catalog name.

Returns:
The catalog name.

getSchemaName

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

Returns:
The schema name.

getDatastoreDate

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

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

addClasses

public void addClasses(String[] classNames,
                       org.datanucleus.ClassLoaderResolver clr)
Method to add several persistable 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

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 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(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(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

getClassNameForObjectID

public String getClassNameForObjectID(Object id,
                                      org.datanucleus.ClassLoaderResolver clr,
                                      org.datanucleus.store.ExecutionContext ec)
Returns the class corresponding to the given object identity. If the identity is an instanceof OID then returns the associated persistable class name. If the identity is a SCOID, return the SCO class. If the identity is a SingleFieldIdentity then returns the associated persistable class name. If the object is an AppID PK, returns the associated PC class (as far as determinable). If the object id is an application id and the user supplies the "ec" 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 identity of some object.
clr - ClassLoader resolver
ec - execution context (optional - to allow check inheritance level in datastore)
Returns:
For datastore identity, return the class of the corresponding object. For application identity, return the class of the corresponding object. Otherwise returns null if unable to tie as the identity of a particular class.

getFieldManagerForResultProcessing

public org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForResultProcessing(org.datanucleus.store.ObjectProvider sm,
                                                                                          Object resultSet,
                                                                                          org.datanucleus.store.mapped.StatementClassMapping resultMappings)
Specified by:
getFieldManagerForResultProcessing in class org.datanucleus.store.mapped.MappedStoreManager

getFieldManagerForResultProcessing

public org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForResultProcessing(org.datanucleus.store.ExecutionContext ec,
                                                                                          Object resultSet,
                                                                                          org.datanucleus.store.mapped.StatementClassMapping resultMappings,
                                                                                          org.datanucleus.metadata.AbstractClassMetaData cmd)
Specified by:
getFieldManagerForResultProcessing in class org.datanucleus.store.mapped.MappedStoreManager

getFieldManagerForStatementGeneration

public org.datanucleus.store.fieldmanager.FieldManager getFieldManagerForStatementGeneration(org.datanucleus.store.ObjectProvider sm,
                                                                                             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 Object getResultValueAtPosition(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

getStrategyValueForGenerator

protected Object getStrategyValueForGenerator(org.datanucleus.store.valuegenerator.ValueGenerator generator,
                                              org.datanucleus.store.ExecutionContext ec)
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
ec - execution context
Returns:
The next value.

getPropertiesForGenerator

protected Properties getPropertiesForGenerator(org.datanucleus.metadata.AbstractClassMetaData cmd,
                                               int absoluteFieldNumber,
                                               org.datanucleus.store.ExecutionContext ec,
                                               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)
ec - execution context
seqmd - Any sequence metadata
tablegenmd - Any table generator metadata
Returns:
The properties to use for this field

getStrategyForNative

protected String getStrategyForNative(org.datanucleus.metadata.AbstractClassMetaData cmd,
                                      int absFieldNumber)
Method defining which value-strategy to use when the user specifies "native".

Overrides:
getStrategyForNative in class org.datanucleus.store.AbstractStoreManager
Returns:
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 SQL type info for the specified JDBC type

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

getSQLTypeInfoForJDBCType

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

Parameters:
jdbcType - JDBC type
sqlType - The SQL type name (if known, otherwise uses the default for this JDBC type).
Returns:
SQL type info
Throws:
org.datanucleus.store.exceptions.UnsupportedDataTypeException - If the JDBC type is not found

getColumnInfoForColumnName

public RDBMSColumnInfo getColumnInfoForColumnName(Table table,
                                                  Connection conn,
                                                  org.datanucleus.store.mapped.DatastoreIdentifier column)
                                           throws 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:
SQLException

getColumnInfoForTable

public List getColumnInfoForTable(Table table,
                                  Connection conn)
                           throws 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:
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 Collection getManagedTables(String catalog,
                                   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(String category,
                             PrintStream ps)
                      throws 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:
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 metadata describing the field/property.
clr - The ClassLoaderResolver
Returns:
The container object (SetTable/ListTable/MapTable/ArrayTable)

getSupportedOptions

public 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.metadata.AbstractClassMetaData acmd,
                                                                              org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
                                                                              boolean ignoreCache,
                                                                              org.datanucleus.FetchPlan fetchPlan,
                                                                              Class persistentClass)
Specified by:
newResultObjectFactory in class org.datanucleus.store.mapped.MappedStoreManager

newFKArrayStore

protected org.datanucleus.store.scostore.ArrayStore newFKArrayStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                    org.datanucleus.ClassLoaderResolver clr)
Overrides:
newFKArrayStore in class org.datanucleus.store.mapped.MappedStoreManager

newFKListStore

protected org.datanucleus.store.scostore.ListStore newFKListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                  org.datanucleus.ClassLoaderResolver clr)
Overrides:
newFKListStore in class org.datanucleus.store.mapped.MappedStoreManager

newFKSetStore

protected org.datanucleus.store.scostore.SetStore newFKSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                org.datanucleus.ClassLoaderResolver clr)
Overrides:
newFKSetStore in class org.datanucleus.store.mapped.MappedStoreManager

newFKMapStore

protected org.datanucleus.store.scostore.MapStore newFKMapStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                org.datanucleus.ClassLoaderResolver clr)
Overrides:
newFKMapStore in class org.datanucleus.store.mapped.MappedStoreManager

newJoinArrayStore

protected org.datanucleus.store.scostore.ArrayStore newJoinArrayStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                      org.datanucleus.ClassLoaderResolver clr,
                                                                      org.datanucleus.store.mapped.DatastoreContainerObject table)
Overrides:
newJoinArrayStore in class org.datanucleus.store.mapped.MappedStoreManager

newJoinMapStore

protected org.datanucleus.store.scostore.MapStore newJoinMapStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                  org.datanucleus.ClassLoaderResolver clr,
                                                                  org.datanucleus.store.mapped.DatastoreContainerObject table)
Overrides:
newJoinMapStore in class org.datanucleus.store.mapped.MappedStoreManager

newJoinListStore

protected org.datanucleus.store.scostore.ListStore newJoinListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                    org.datanucleus.ClassLoaderResolver clr,
                                                                    org.datanucleus.store.mapped.DatastoreContainerObject table)
Overrides:
newJoinListStore in class org.datanucleus.store.mapped.MappedStoreManager

newJoinSetStore

protected org.datanucleus.store.scostore.SetStore newJoinSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                  org.datanucleus.ClassLoaderResolver clr,
                                                                  org.datanucleus.store.mapped.DatastoreContainerObject table)
Overrides:
newJoinSetStore in class org.datanucleus.store.mapped.MappedStoreManager

newPersistableRelationStore

protected org.datanucleus.store.scostore.PersistableRelationStore newPersistableRelationStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                                                                              org.datanucleus.ClassLoaderResolver clr,
                                                                                              org.datanucleus.store.mapped.DatastoreContainerObject table)
Overrides:
newPersistableRelationStore in class org.datanucleus.store.mapped.MappedStoreManager

usesBackedSCOWrappers

public boolean usesBackedSCOWrappers()
Specified by:
usesBackedSCOWrappers in interface org.datanucleus.store.StoreManager
Overrides:
usesBackedSCOWrappers in class org.datanucleus.store.AbstractStoreManager

useBackedSCOWrapperForMember

public boolean useBackedSCOWrapperForMember(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                            org.datanucleus.store.ExecutionContext ec)
Specified by:
useBackedSCOWrapperForMember in interface org.datanucleus.store.StoreManager
Overrides:
useBackedSCOWrapperForMember in class org.datanucleus.store.AbstractStoreManager

getCalendarForDateTimezone

public Calendar getCalendarForDateTimezone()
Accessor for the Calendar to be used in handling all timezone issues with the datastore. Utilises the "serverTimeZoneID" in providing this Calendar used in time/date conversions.

Returns:
The calendar to use for dateTimezone issues.

createSchema

public void createSchema(Set<String> inputClassNames,
                         Properties props)
Specified by:
createSchema in interface org.datanucleus.store.schema.SchemaAwareStoreManager

createSchemaSequences

protected void createSchemaSequences(Set<String> classNames,
                                     org.datanucleus.ClassLoaderResolver clr,
                                     FileWriter ddlWriter)

addSequenceTableForMetaData

protected void addSequenceTableForMetaData(org.datanucleus.metadata.MetaData md,
                                           org.datanucleus.ClassLoaderResolver clr,
                                           Set<String> seqTablesGenerated)

addSequenceForMetaData

protected void addSequenceForMetaData(org.datanucleus.metadata.MetaData md,
                                      String seq,
                                      org.datanucleus.ClassLoaderResolver clr,
                                      Set<String> sequencesGenerated,
                                      FileWriter ddlWriter)

deleteSchema

public void deleteSchema(Set<String> inputClassNames,
                         Properties props)
Specified by:
deleteSchema in interface org.datanucleus.store.schema.SchemaAwareStoreManager

validateSchema

public void validateSchema(Set<String> inputClassNames,
                           Properties props)
Specified by:
validateSchema in interface org.datanucleus.store.schema.SchemaAwareStoreManager

cleanInputClassNames

protected static Set<String> cleanInputClassNames(org.datanucleus.NucleusContext ctx,
                                                  Set<String> inputClassNames)
Method to generate a set of class names using the input list. If no input class names are provided then uses the list of classes known to have metadata.

Parameters:
ctx - NucleusContext
inputClassNames - Class names to start from
Returns:
The set of class names


Copyright © 2012. All Rights Reserved.