Package org.datanucleus.store.rdbms
Class RDBMSStoreManager
- java.lang.Object
-
- org.datanucleus.properties.PropertyStore
-
- org.datanucleus.store.AbstractStoreManager
-
- org.datanucleus.store.rdbms.RDBMSStoreManager
-
- All Implemented Interfaces:
org.datanucleus.store.BackedSCOStoreManager,org.datanucleus.store.schema.SchemaAwareStoreManager,org.datanucleus.store.schema.SchemaScriptAwareStoreManager,org.datanucleus.store.StoreManager
public class RDBMSStoreManager extends org.datanucleus.store.AbstractStoreManager implements org.datanucleus.store.BackedSCOStoreManager, org.datanucleus.store.schema.SchemaAwareStoreManager, org.datanucleus.store.schema.SchemaScriptAwareStoreManagerStoreManager 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 :
- creates and controls access to the data sources required for this datastore instance
- implements insert(), fetch(), update(), delete() in the interface to StateManager.
- Providing cached access to JDBC database metadata (in particular column information).
- Resolving SQL identifier macros to actual SQL identifiers.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringcatalogNameDefault catalog name for the datastore.protected DatastoreAdapterdbaAdapter for the datastore being used.protected SQLExpressionFactoryexpressionFactoryFactory for expressions using the generic query SQL mechanism.protected IdentifierFactoryidentifierFactoryFactory for identifiers for this datastore.protected Map<org.datanucleus.state.DNStateManager,DatastoreClass>insertedDatastoreClassByStateManagerMap of DatastoreClass keyed by StateManager, for objects currently being inserted.protected MappingManagermappingManagerManager for the mapping between Java and datastore types.static StringMETADATA_NONDURABLE_REQUIRES_TABLEprotected ReadWriteLockschemaLockLock object aimed at providing a lock on the schema definition managed here, preventing reads while it is being updated etc.protected StringschemaNameDefault schema name for the datastore.-
Fields inherited from class org.datanucleus.store.AbstractStoreManager
connectionMgr, flushProcess, namingFactory, nucleusContext, persistenceHandler, queryMgr, schemaHandler, storeDataMgr, storeManagerKey, valueGenerationMgr
-
Fields inherited from interface org.datanucleus.store.StoreManager
OPTION_APPLICATION_COMPOSITE_ID, OPTION_APPLICATION_ID, OPTION_DATASTORE_ID, OPTION_DATASTORE_TIME_STORES_MILLISECS, OPTION_DATASTORE_TIME_STORES_NANOSECS, OPTION_DATASTORE_TIMEOUT, OPTION_NONDURABLE_ID, OPTION_ORM, OPTION_ORM_EMBEDDED_ARRAY, OPTION_ORM_EMBEDDED_ARRAY_NESTED, OPTION_ORM_EMBEDDED_COLLECTION, OPTION_ORM_EMBEDDED_COLLECTION_NESTED, OPTION_ORM_EMBEDDED_MAP, OPTION_ORM_EMBEDDED_MAP_NESTED, OPTION_ORM_EMBEDDED_PC, OPTION_ORM_EMBEDDED_PC_NESTED, OPTION_ORM_FOREIGN_KEYS, OPTION_ORM_INHERITANCE_COMPLETE_TABLE, OPTION_ORM_INHERITANCE_JOINED_TABLE, OPTION_ORM_INHERITANCE_SINGLE_TABLE, OPTION_ORM_SECONDARY_TABLE, OPTION_ORM_SERIALISED_ARRAY_ELEMENT, OPTION_ORM_SERIALISED_COLLECTION_ELEMENT, OPTION_ORM_SERIALISED_MAP_KEY, OPTION_ORM_SERIALISED_MAP_VALUE, OPTION_ORM_SERIALISED_PC, OPTION_QUERY_CANCEL, OPTION_QUERY_JDOQL_BITWISE_OPS, OPTION_QUERY_JDOQL_BULK_DELETE, OPTION_QUERY_JDOQL_BULK_INSERT, OPTION_QUERY_JDOQL_BULK_UPDATE, OPTION_QUERY_JPQL_BULK_DELETE, OPTION_QUERY_JPQL_BULK_INSERT, OPTION_QUERY_JPQL_BULK_UPDATE, OPTION_TRANSACTION_ACID, OPTION_TXN_ISOLATION_READ_COMMITTED, OPTION_TXN_ISOLATION_READ_UNCOMMITTED, OPTION_TXN_ISOLATION_REPEATABLE_READ, OPTION_TXN_ISOLATION_SERIALIZABLE, RELATION_IDENTITY_STORAGE_PERSISTABLE_IDENTITY
-
-
Constructor Summary
Constructors Constructor Description RDBMSStoreManager(org.datanucleus.ClassLoaderResolver clr, org.datanucleus.PersistenceNucleusContext ctx, Map<String,Object> props)Constructs a new RDBMSManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSchemaCallback(String className, org.datanucleus.metadata.AbstractMemberMetaData mmd)protected voidaddSequenceForMetaData(org.datanucleus.metadata.MetaData md, String seq, org.datanucleus.ClassLoaderResolver clr, Set<String> sequencesGenerated, FileWriter ddlWriter)protected voidaddSequenceTableForMetaData(org.datanucleus.metadata.MetaData md, org.datanucleus.ClassLoaderResolver clr, Set<String> seqTablesGenerated)voidaddWrittenDdlStatement(String stmt)When we are in SchemaTool DDL mode, add a new DDL statement.booleanallowsBatching()Convenience method to return if the datastore supports batching and the user wants batching.voidclose()Release of resourcesvoidcreateDatabase(String catalogName, String schemaName, Properties props)voidcreateSchemaForClasses(Set<String> classNames, Properties props)protected voidcreateSchemaSequences(Set<String> classNames, org.datanucleus.ClassLoaderResolver clr, FileWriter ddlWriter)voiddeleteDatabase(String catalogName, String schemaName, Properties props)voiddeleteSchemaForClasses(Set<String> classNames, Properties props)voidexecuteScript(String script)org.datanucleus.store.types.scostore.StoregetBackingStoreForField(org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.AbstractMemberMetaData mmd, Class type)Accessor for the backing store for the specified member.CalendargetCalendarForDateTimezone()Accessor for the Calendar to be used in handling all timezone issues with the datastore.org.datanucleus.metadata.AbstractClassMetaData[]getClassesManagingTableForClass(org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.ClassLoaderResolver clr)Method to return the class(es) that has a table managing the persistence of the fields of the supplied class.StringgetClassNameForObjectID(Object id, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.ExecutionContext ec)Returns the class corresponding to the given object identity.RDBMSColumnInfogetColumnInfoForColumnName(Table table, Connection conn, DatastoreIdentifier column)Returns the column info for a column name.List<org.datanucleus.store.schema.StoreSchemaData>getColumnInfoForTable(Table table, Connection conn)Returns the column info for a database table.booleangetCompleteDDL()Accessor for whether we should generate complete DDL when in that mode.DatastoreAdaptergetDatastoreAdapter()Gets the DatastoreAdapter to use for this store.DatastoreClassgetDatastoreClass(String className, org.datanucleus.ClassLoaderResolver clr)Returns the primary datastore table serving as backing for the given class.DatastoreClassgetDatastoreClass(DatastoreIdentifier name)Returns the datastore table having the given identifier.DategetDatastoreDate()Get the date/time of the datastore.WritergetDdlWriter()Accessor for the writer for DDL (if set).StringgetDefaultCatalogName()StringgetDefaultIdentifierCase()Method to return the default identifier case.StringgetDefaultSchemaName()StringgetDefaultStateManagerClassName()org.datanucleus.store.types.scostore.StoregetExistingBackingStoreForMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)IdentifierFactorygetIdentifierFactory()Accessor for the factory for creating identifiers (table/column names etc).Collection<Table>getManagedTables(String catalog, String schema)Convenience accessor of the Table objects managed in this datastore at this point.MappingManagergetMappingManager()Gets the MappingManager to use for this store.StringgetNativeQueryLanguage()protected ObjectgetNextValueForValueGenerator(org.datanucleus.store.valuegenerator.ValueGenerator generator, org.datanucleus.ExecutionContext ec)Accessor for the next value from the specified ValueGenerator.org.datanucleus.store.NucleusSequencegetNucleusSequence(org.datanucleus.ExecutionContext ec, org.datanucleus.metadata.SequenceMetaData seqmd)Method to return a datastore sequence for this datastore matching the passed sequence MetaData.protected PropertiesgetPropertiesForValueGenerator(org.datanucleus.metadata.AbstractClassMetaData cmd, int absoluteFieldNumber, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.SequenceMetaData seqmd, org.datanucleus.metadata.TableGeneratorMetaData tablegenmd)Method to return the properties to pass to the ValueGenerator for the specified field.StringgetQueryCacheKey()ObjectgetResultValueAtPosition(ResultSet rs, JavaTypeMapping mapping, int position)Method to return the value from the results for the mapping at the specified position.Map<String,Collection<org.datanucleus.metadata.AbstractMemberMetaData>>getSchemaCallbacks()SQLControllergetSQLController()Accessor for the SQL controller.SQLExpressionFactorygetSQLExpressionFactory()Accessor for the SQL expression factory to use when generating SQL statements.SQLTypeInfogetSQLTypeInfoForJDBCType(int jdbcType)Accessor for the SQL type info for the specified JDBC typeSQLTypeInfogetSQLTypeInfoForJDBCType(int jdbcType, String sqlType)Accessor for the SQL type info for the specified JDBC type.org.datanucleus.store.StoreData[]getStoreDataForDatastoreContainerObject(DatastoreIdentifier tableIdentifier)Utility to return all StoreData for a Datastore Container identifier.CollectiongetSupportedOptions()Accessor for the supported options in string formCollection<String>getSupportedQueryLanguages()TablegetTable(org.datanucleus.metadata.AbstractMemberMetaData mmd)Returns the datastore container (table) for the specified field.StringgetValueGenerationStrategyForNative(org.datanucleus.metadata.AbstractClassMetaData cmd)StringgetValueGenerationStrategyForNative(org.datanucleus.metadata.AbstractMemberMetaData mmd)booleanhasWrittenDdlStatement(String stmt)When we are in SchemaTool DDL mode, return if the supplied statement is already present.protected voidinitialiseIdentifierFactory(org.datanucleus.NucleusContext nucleusContext)Method to create the IdentifierFactory to be used by this store.voidinvalidateColumnInfoForTable(Table table)Method to invalidate the cached column info for a table.booleanisJdbcStore()booleanisObjectInserted(org.datanucleus.state.DNStateManager sm, int fieldNumber)Accessor for whether the specified field of the object is inserted in the datastore yet.booleanisObjectInserted(org.datanucleus.state.DNStateManager sm, String className)Returns whether this object is inserted in the datastore far enough to be considered to be the supplied type.protected voidlogConfiguration()Convenience method to log the configuration of this store manager.voidmanageClasses(org.datanucleus.ClassLoaderResolver clr, String... classNames)Method to add several persistable classes to the store manager's set of supported classes.TablenewJoinTable(Table ownerTable, org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr)Called by (container) Mapping objects to request the creation of a join table.org.datanucleus.store.query.QuerynewQuery(String language, org.datanucleus.ExecutionContext ec)org.datanucleus.store.query.QuerynewQuery(String language, org.datanucleus.ExecutionContext ec, String queryString)org.datanucleus.store.query.QuerynewQuery(String language, org.datanucleus.ExecutionContext ec, org.datanucleus.store.query.Query q)voidprintInformation(String category, PrintStream ps)Method to output particular information owned by this datastore.voidregisterTableInitialized(Table table)voidresolveIdentifierMacro(org.datanucleus.util.MacroString.IdentifierMacro im, org.datanucleus.ClassLoaderResolver clr)Resolves an identifier macro.voidsetObjectIsInsertedToLevel(org.datanucleus.state.DNStateManager sm, DatastoreClass table)Method to set that the specified object is inserted down to the defined datastore class.booleansupportsQueryLanguage(String language)booleansupportsValueGenerationStrategy(String strategy)Accessor for whether this value strategy is supported.voidunmanageAllClasses(org.datanucleus.ClassLoaderResolver clr)Utility to remove all classes that we are managing.booleanuseBackedSCOWrapperForMember(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ExecutionContext ec)booleanusesBackedSCOWrappers()voidvalidateSchemaForClasses(Set<String> classNames, Properties props)voidvalidateTable(TableImpl table, org.datanucleus.ClassLoaderResolver clr)Utility to validate the specified table.-
Methods inherited from class org.datanucleus.store.AbstractStoreManager
addValueGenerationPropertiesForIncrement, addValueGenerationPropertiesForSequence, deregisterAllStoreData, enableSchemaGeneration, getApiAdapter, getBooleanObjectProperty, getBooleanProperty, getBooleanProperty, getConnectionManager, getConnectionPassword, getExtent, getFlushProcess, getIntProperty, getMetaDataManager, getNamingFactory, getNucleusConnection, getNucleusContext, getPersistenceHandler, getProperty, getQueryManager, getSchemaHandler, getStoreDataForClass, getStoreManagerKey, getStringProperty, getSubClassesForClass, getValueGenerationManager, getValueGenerationStrategyValue, getValueGeneratorForMember, hasProperty, isClosed, isValueGenerationStrategyDatastoreAttributed, manageClassForIdentity, managesClass, newStoreData, registerConnectionMgr, registerStoreData, resetSchemaGeneration, unmanageClass
-
Methods inherited from class org.datanucleus.properties.PropertyStore
getFrequentProperties, hasPropertyNotNull, setPropertyInternal
-
-
-
-
Field Detail
-
METADATA_NONDURABLE_REQUIRES_TABLE
public static final String METADATA_NONDURABLE_REQUIRES_TABLE
- See Also:
- Constant Field Values
-
dba
protected DatastoreAdapter dba
Adapter for the datastore being used.
-
identifierFactory
protected IdentifierFactory identifierFactory
Factory for identifiers for this datastore.
-
catalogName
protected String catalogName
Default catalog name for the datastore.
-
schemaName
protected String schemaName
Default schema name for the datastore.
-
mappingManager
protected MappingManager mappingManager
Manager for the mapping between Java and datastore types.
-
insertedDatastoreClassByStateManager
protected Map<org.datanucleus.state.DNStateManager,DatastoreClass> insertedDatastoreClassByStateManager
Map of DatastoreClass keyed by StateManager, for objects currently being inserted. Defines to what level an object is inserted in the datastore.
-
schemaLock
protected ReadWriteLock schemaLock
Lock object aimed at providing a lock on the schema definition managed here, preventing reads while it is being updated etc.
-
expressionFactory
protected SQLExpressionFactory expressionFactory
Factory for expressions using the generic query SQL mechanism.
-
-
Constructor Detail
-
RDBMSStoreManager
public RDBMSStoreManager(org.datanucleus.ClassLoaderResolver clr, org.datanucleus.PersistenceNucleusContext 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 ClassLoaderResolverctx- 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:
getQueryCacheKeyin interfaceorg.datanucleus.store.StoreManager
-
initialiseIdentifierFactory
protected void initialiseIdentifierFactory(org.datanucleus.NucleusContext nucleusContext)
Method to create the IdentifierFactory to be used by this store. Relies on the datastore adapter existing before creation- Parameters:
nucleusContext- context
-
getIdentifierFactory
public IdentifierFactory getIdentifierFactory()
Accessor for the factory for creating identifiers (table/column names etc).- Returns:
- Identifier factory
-
getDatastoreAdapter
public DatastoreAdapter getDatastoreAdapter()
Gets the DatastoreAdapter to use for this store.- Returns:
- Returns the DatastoreAdapter
-
getMappingManager
public MappingManager getMappingManager()
Gets the MappingManager to use for this store.- Returns:
- Returns the MappingManager.
-
getDefaultStateManagerClassName
public String getDefaultStateManagerClassName()
- Specified by:
getDefaultStateManagerClassNamein interfaceorg.datanucleus.store.StoreManager- Overrides:
getDefaultStateManagerClassNamein classorg.datanucleus.store.AbstractStoreManager
-
getStoreDataForDatastoreContainerObject
public org.datanucleus.store.StoreData[] getStoreDataForDatastoreContainerObject(DatastoreIdentifier tableIdentifier)
Utility to return all StoreData for a Datastore Container identifier. Returns StoreData with this table identifier and where the class is the owner of the table.- Parameters:
tableIdentifier- Identifier for the table- Returns:
- The StoreData for this table (if managed).
-
getTable
public Table getTable(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Returns the datastore container (table) for the specified field. Returns 'null' if the field is not (yet) known to the store manager. Note : if we have an embedded object (embedded into something else) that has a member which requires a join table, then this method will not cater for having different tables for the different places that the object can be embedded.- Parameters:
mmd- The metadata for the field.- Returns:
- The corresponding datastore container, or 'null'.
-
getDatastoreClass
public DatastoreClass getDatastoreClass(String className, org.datanucleus.ClassLoaderResolver clr)
Returns the primary datastore table serving as backing for the given class. If the class is not yet known to the store manager,manageClasses(org.datanucleus.ClassLoaderResolver, java.lang.String...)is called to add it. Classes which have inheritance strategy of "new-table" and "superclass-table" will return a table here, whereas "subclass-table" will return null since it doesn't have a table as such.- Parameters:
className- Name of the class whose table is be returned.clr- The ClassLoaderResolver- Returns:
- The corresponding class table.
- Throws:
NoTableManagedException- If the given class has no table managed in the database.
-
getDatastoreClass
public DatastoreClass getDatastoreClass(DatastoreIdentifier name)
Returns the datastore table having the given identifier. Returns 'null' if no such table is (yet) known to the store manager.- Parameters:
name- The identifier name of the table.- Returns:
- The corresponding table, or 'null'
-
getClassesManagingTableForClass
public org.datanucleus.metadata.AbstractClassMetaData[] getClassesManagingTableForClass(org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.ClassLoaderResolver clr)Method to return the class(es) that has a table managing the persistence of the fields of the supplied class. For the 3 inheritance strategies, the following occurs :-- new-table : will return the same ClassMetaData
- subclass-table : will return all subclasses that have a table managing its fields
- superclass-table : will return the next superclass that has a table
- Parameters:
cmd- The supplied class.clr- ClassLoader resolver- Returns:
- The ClassMetaData's managing the fields of the supplied class
-
isObjectInserted
public boolean isObjectInserted(org.datanucleus.state.DNStateManager sm, int fieldNumber)Accessor for whether the specified field of the object is inserted in the datastore yet.- Parameters:
sm- StateManager for the objectfieldNumber- (Absolute) field number for the object- Returns:
- Whether it is persistent
-
isObjectInserted
public boolean isObjectInserted(org.datanucleus.state.DNStateManager sm, String className)Returns whether this object is inserted in the datastore far enough to be considered to be the supplied type. For example if we have base class A, B extends A and this object is a B, and we pass in A here then this returns whether the A part of the object is now inserted.- Parameters:
sm- StateManager for the objectclassName- Name of class that we want to check the insertion level for.- Returns:
- Whether the object is inserted in the datastore to this level
-
setObjectIsInsertedToLevel
public void setObjectIsInsertedToLevel(org.datanucleus.state.DNStateManager sm, DatastoreClass table)Method to set that the specified object is inserted down to the defined datastore class. When the object is fully inserted (the table is the primary table for this object type) it is removed from the map of objects being inserted.- Parameters:
sm- StateManager for the objecttable- Table to which it is now inserted
-
getExistingBackingStoreForMember
public org.datanucleus.store.types.scostore.Store getExistingBackingStoreForMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
-
getBackingStoreForField
public org.datanucleus.store.types.scostore.Store getBackingStoreForField(org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.AbstractMemberMetaData mmd, Class type)Accessor for the backing store for the specified member. Note : if we have an embedded object that is embedded into some other type and the object has a member that requires a join table (backing store), this method will not cater for the different places that can be embedded.- Specified by:
getBackingStoreForFieldin interfaceorg.datanucleus.store.BackedSCOStoreManager- Parameters:
clr- The ClassLoaderResolvermmd- metadata for the member to be persisted by this Storetype- instantiated type or prefered type- Returns:
- The backing store
-
getDefaultIdentifierCase
public String getDefaultIdentifierCase()
Method to return the default identifier case.- Returns:
- Identifier case to use if not specified by the user
-
getSchemaCallbacks
public Map<String,Collection<org.datanucleus.metadata.AbstractMemberMetaData>> getSchemaCallbacks()
-
addSchemaCallback
public void addSchemaCallback(String className, org.datanucleus.metadata.AbstractMemberMetaData mmd)
-
isJdbcStore
public boolean isJdbcStore()
- Specified by:
isJdbcStorein interfaceorg.datanucleus.store.StoreManager- Overrides:
isJdbcStorein classorg.datanucleus.store.AbstractStoreManager
-
getNativeQueryLanguage
public String getNativeQueryLanguage()
- Specified by:
getNativeQueryLanguagein interfaceorg.datanucleus.store.StoreManager
-
getSupportedQueryLanguages
public Collection<String> getSupportedQueryLanguages()
- Specified by:
getSupportedQueryLanguagesin interfaceorg.datanucleus.store.StoreManager- Overrides:
getSupportedQueryLanguagesin classorg.datanucleus.store.AbstractStoreManager
-
supportsQueryLanguage
public boolean supportsQueryLanguage(String language)
- Specified by:
supportsQueryLanguagein interfaceorg.datanucleus.store.StoreManager- Overrides:
supportsQueryLanguagein classorg.datanucleus.store.AbstractStoreManager
-
newQuery
public org.datanucleus.store.query.Query newQuery(String language, org.datanucleus.ExecutionContext ec)
- Specified by:
newQueryin interfaceorg.datanucleus.store.StoreManager
-
newQuery
public org.datanucleus.store.query.Query newQuery(String language, org.datanucleus.ExecutionContext ec, String queryString)
- Specified by:
newQueryin interfaceorg.datanucleus.store.StoreManager
-
newQuery
public org.datanucleus.store.query.Query newQuery(String language, org.datanucleus.ExecutionContext ec, org.datanucleus.store.query.Query q)
- Specified by:
newQueryin interfaceorg.datanucleus.store.StoreManager
-
logConfiguration
protected void logConfiguration()
Convenience method to log the configuration of this store manager.- Overrides:
logConfigurationin classorg.datanucleus.store.AbstractStoreManager
-
close
public void close()
Release of resources- Specified by:
closein interfaceorg.datanucleus.store.StoreManager- Overrides:
closein classorg.datanucleus.store.AbstractStoreManager
-
getNucleusSequence
public org.datanucleus.store.NucleusSequence getNucleusSequence(org.datanucleus.ExecutionContext ec, org.datanucleus.metadata.SequenceMetaData seqmd)Method to return a datastore sequence for this datastore matching the passed sequence MetaData.- Specified by:
getNucleusSequencein interfaceorg.datanucleus.store.StoreManager- Parameters:
ec- execution contextseqmd- SequenceMetaData- Returns:
- The Sequence
-
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
-
getDefaultCatalogName
public String getDefaultCatalogName()
- Specified by:
getDefaultCatalogNamein interfaceorg.datanucleus.store.StoreManager
-
getDefaultSchemaName
public String getDefaultSchemaName()
- Specified by:
getDefaultSchemaNamein interfaceorg.datanucleus.store.StoreManager
-
getDatastoreDate
public Date getDatastoreDate()
Get the date/time of the datastore.- Specified by:
getDatastoreDatein interfaceorg.datanucleus.store.StoreManager- Returns:
- Date/time of the datastore
-
manageClasses
public void manageClasses(org.datanucleus.ClassLoaderResolver clr, String... classNames)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:
manageClassesin interfaceorg.datanucleus.store.StoreManager- Overrides:
manageClassesin classorg.datanucleus.store.AbstractStoreManager- Parameters:
clr- The ClassLoaderResolverclassNames- Name of the class(es) to be added.
-
unmanageAllClasses
public void unmanageAllClasses(org.datanucleus.ClassLoaderResolver clr)
Utility to remove all classes that we are managing.- Specified by:
unmanageAllClassesin interfaceorg.datanucleus.store.StoreManager- Overrides:
unmanageAllClassesin classorg.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:
table- The table to validateclr- The ClassLoaderResolver
-
getClassNameForObjectID
public String getClassNameForObjectID(Object id, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.ExecutionContext ec)
Returns the class corresponding to the given object identity. If the identity is a SCOID, return the SCO class. If the identity is a DatastoreId then returns the associated persistable class name. 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:
getClassNameForObjectIDin interfaceorg.datanucleus.store.StoreManager- Overrides:
getClassNameForObjectIDin classorg.datanucleus.store.AbstractStoreManager- Parameters:
id- The identity of some object.clr- ClassLoader resolverec- 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.
-
getResultValueAtPosition
public Object getResultValueAtPosition(ResultSet rs, JavaTypeMapping mapping, int position)
Method to return the value from the results for the mapping at the specified position.- Parameters:
rs- The resultsmapping- The mappingposition- The position in the results- Returns:
- The value at that position
- Throws:
org.datanucleus.exceptions.NucleusDataStoreException- if an error occurs accessing the results
-
getNextValueForValueGenerator
protected Object getNextValueForValueGenerator(org.datanucleus.store.valuegenerator.ValueGenerator generator, org.datanucleus.ExecutionContext ec)
Accessor for the next value from the specified ValueGenerator. This implementation caters for datastore-specific generators and provides synchronisation on the connection to the datastore.- Overrides:
getNextValueForValueGeneratorin classorg.datanucleus.store.AbstractStoreManager- Parameters:
generator- The generatorec- execution context- Returns:
- The next value.
-
getPropertiesForValueGenerator
protected Properties getPropertiesForValueGenerator(org.datanucleus.metadata.AbstractClassMetaData cmd, int absoluteFieldNumber, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.SequenceMetaData seqmd, org.datanucleus.metadata.TableGeneratorMetaData tablegenmd)
Method to return the properties to pass to the ValueGenerator for the specified field.- Overrides:
getPropertiesForValueGeneratorin classorg.datanucleus.store.AbstractStoreManager- Parameters:
cmd- MetaData for the classabsoluteFieldNumber- Number of the field (-1 = datastore identity)clr- ClassLoader resolverseqmd- Any sequence metadatatablegenmd- Any table generator metadata- Returns:
- The properties to use for this field
-
supportsValueGenerationStrategy
public boolean supportsValueGenerationStrategy(String strategy)
Accessor for whether this value strategy is supported. Overrides the setting in the superclass for identity/sequence if the adapter doesn't support them.- Specified by:
supportsValueGenerationStrategyin interfaceorg.datanucleus.store.StoreManager- Overrides:
supportsValueGenerationStrategyin classorg.datanucleus.store.AbstractStoreManager- Parameters:
strategy- The strategy- Returns:
- Whether it is supported.
-
getValueGenerationStrategyForNative
public String getValueGenerationStrategyForNative(org.datanucleus.metadata.AbstractClassMetaData cmd)
- Specified by:
getValueGenerationStrategyForNativein interfaceorg.datanucleus.store.StoreManager- Overrides:
getValueGenerationStrategyForNativein classorg.datanucleus.store.AbstractStoreManager
-
getValueGenerationStrategyForNative
public String getValueGenerationStrategyForNative(org.datanucleus.metadata.AbstractMemberMetaData mmd)
- Specified by:
getValueGenerationStrategyForNativein interfaceorg.datanucleus.store.StoreManager- Overrides:
getValueGenerationStrategyForNativein classorg.datanucleus.store.AbstractStoreManager
-
getSQLTypeInfoForJDBCType
public SQLTypeInfo getSQLTypeInfoForJDBCType(int jdbcType) throws UnsupportedDataTypeException
Accessor for the SQL type info for the specified JDBC type- Parameters:
jdbcType- JDBC type- Returns:
- (default) SQL type info
- Throws:
UnsupportedDataTypeException- If the JDBC type is not found
-
getSQLTypeInfoForJDBCType
public SQLTypeInfo getSQLTypeInfoForJDBCType(int jdbcType, String sqlType) throws UnsupportedDataTypeException
Accessor for the SQL type info for the specified JDBC type.- Parameters:
jdbcType- JDBC typesqlType- The SQL type name (if known, otherwise uses the default for this JDBC type).- Returns:
- SQL type info
- Throws:
UnsupportedDataTypeException- If the JDBC type is not found
-
getColumnInfoForColumnName
public RDBMSColumnInfo getColumnInfoForColumnName(Table table, Connection conn, 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/viewconn- JDBC connection to the database.column- the column- Returns:
- The ColumnInfo objects describing the column.
- Throws:
SQLException- Thrown if an error occurs
-
getColumnInfoForTable
public List<org.datanucleus.store.schema.StoreSchemaData> 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/viewconn- 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- Thrown if an error occurs
-
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<Table> 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 (or null to not restrict)schema- Name of the schema to restrict the collection by (or null to not restrict)- Returns:
- Collection of tables
-
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:
printInformationin interfaceorg.datanucleus.store.StoreManager- Overrides:
printInformationin classorg.datanucleus.store.AbstractStoreManager- Parameters:
category- Category of informationps- PrintStream- Throws:
Exception- Thrown if an error occurs in the output process
-
executeScript
public void executeScript(String script)
- Specified by:
executeScriptin interfaceorg.datanucleus.store.schema.SchemaScriptAwareStoreManager
-
getSupportedOptions
public Collection getSupportedOptions()
Accessor for the supported options in string form- Specified by:
getSupportedOptionsin interfaceorg.datanucleus.store.StoreManager- Overrides:
getSupportedOptionsin classorg.datanucleus.store.AbstractStoreManager
-
allowsBatching
public boolean allowsBatching()
Convenience method to return if the datastore supports batching and the user wants batching.- Returns:
- If batching of statements is permissible
-
usesBackedSCOWrappers
public boolean usesBackedSCOWrappers()
- Specified by:
usesBackedSCOWrappersin interfaceorg.datanucleus.store.StoreManager
-
useBackedSCOWrapperForMember
public boolean useBackedSCOWrapperForMember(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ExecutionContext ec)- Specified by:
useBackedSCOWrapperForMemberin interfaceorg.datanucleus.store.StoreManager- Overrides:
useBackedSCOWrapperForMemberin classorg.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.
-
newJoinTable
public Table newJoinTable(Table ownerTable, org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.ClassLoaderResolver clr)
Called by (container) Mapping objects to request the creation of a join 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.- Parameters:
ownerTable- The table that owns this member.mmd- The metadata describing the field/property.clr- The ClassLoaderResolver- Returns:
- The table (SetTable/ListTable/MapTable/ArrayTable)
-
registerTableInitialized
public void registerTableInitialized(Table table)
-
createDatabase
public void createDatabase(String catalogName, String schemaName, Properties props)
- Specified by:
createDatabasein interfaceorg.datanucleus.store.schema.SchemaAwareStoreManager
-
deleteDatabase
public void deleteDatabase(String catalogName, String schemaName, Properties props)
- Specified by:
deleteDatabasein interfaceorg.datanucleus.store.schema.SchemaAwareStoreManager
-
createSchemaForClasses
public void createSchemaForClasses(Set<String> classNames, Properties props)
- Specified by:
createSchemaForClassesin interfaceorg.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)
-
deleteSchemaForClasses
public void deleteSchemaForClasses(Set<String> classNames, Properties props)
- Specified by:
deleteSchemaForClassesin interfaceorg.datanucleus.store.schema.SchemaAwareStoreManager
-
validateSchemaForClasses
public void validateSchemaForClasses(Set<String> classNames, Properties props)
- Specified by:
validateSchemaForClassesin interfaceorg.datanucleus.store.schema.SchemaAwareStoreManager
-
-