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.SchemaScriptAwareStoreManager
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 :
- 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classA schema transaction that adds a set of classes to the RDBMSManager, making them usable for persistence. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringDefault catalog name for the datastore.private RDBMSStoreManager.ClassAdderThe active class adder transaction, if any.private booleanFlag for when generating schema as DDL and wanting complete DDL (as opposed to upgrade DDL).private CalendarCalendar for this datastore.protected DatastoreAdapterAdapter for the datastore being used.private WriterWriter for use when this RDBMSManager is configured to write DDL.protected SQLExpressionFactoryFactory for expressions using the generic query SQL mechanism.protected IdentifierFactoryFactory for identifiers for this datastore.protected Map<org.datanucleus.state.DNStateManager, DatastoreClass> Map of DatastoreClass keyed by StateManager, for objects currently being inserted.protected MappingManagerManager for the mapping between Java and datastore types.static final String(package private) booleanprivate Map<String, Collection<org.datanucleus.metadata.AbstractMemberMetaData>> State variable for schema generation of the callback information to be processed.protected ReadWriteLockLock object aimed at providing a lock on the schema definition managed here, preventing reads while it is being updated etc.protected StringDefault schema name for the datastore.private SQLControllerController for SQL executed on this store.DDL statements already written when in DDL mode.Fields inherited from class org.datanucleus.store.AbstractStoreManager
connectionMgr, flushProcess, namingFactory, nucleusContext, persistenceHandler, queryMgr, schemaHandler, storeDataMgr, storeManagerKey, valueGenerationMgrFields inherited from class org.datanucleus.properties.PropertyStore
frequentProperties, propertiesFields 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
ConstructorsConstructorDescriptionRDBMSStoreManager(org.datanucleus.ClassLoaderResolver clr, org.datanucleus.PersistenceNucleusContext ctx, Map<String, Object> props) Constructs a new RDBMSManager. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSchemaCallback(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.booleanConvenience method to return if the datastore supports batching and the user wants batching.private voidClears all knowledge of tables, cached requests, metadata, etc and resets the store manager to its initial state.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.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.getClassNameForObjectID(Object id, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.ExecutionContext ec) Returns the class corresponding to the given object identity.getColumnInfoForColumnName(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.booleanAccessor for whether we should generate complete DDL when in that mode.Gets the DatastoreAdapter to use for this store.getDatastoreClass(String className, org.datanucleus.ClassLoaderResolver clr) Returns the primary datastore table serving as backing for the given class.Returns the datastore table having the given identifier.Get the date/time of the datastore.Accessor for the writer for DDL (if set).Method to return the default identifier case.org.datanucleus.store.types.scostore.StoregetExistingBackingStoreForMember(org.datanucleus.metadata.AbstractMemberMetaData mmd) Accessor for the factory for creating identifiers (table/column names etc).getManagedTables(String catalog, String schema) Convenience accessor of the Table objects managed in this datastore at this point.Gets the MappingManager to use for this store.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.getResultValueAtPosition(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>> Accessor for the SQL controller.Accessor for the SQL expression factory to use when generating SQL statements.getSQLTypeInfoForJDBCType(int jdbcType) Accessor for the SQL type info for the specified JDBC typegetSQLTypeInfoForJDBCType(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.getTable(org.datanucleus.metadata.AbstractMemberMetaData mmd) Returns the datastore container (table) for the specified field.private DatastoreClassgetTableForStrategy(org.datanucleus.metadata.AbstractClassMetaData cmd, int fieldNumber, org.datanucleus.ClassLoaderResolver clr) getValueGenerationStrategyForNative(org.datanucleus.metadata.AbstractClassMetaData cmd) getValueGenerationStrategyForNative(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.private voidinitialiseSchema(Connection conn, org.datanucleus.ClassLoaderResolver clr) Initialises the schema name for the datastore, and (optionally) the schema table.voidMethod to invalidate the cached column info for a table.booleanbooleanisObjectInserted(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 voidConvenience 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.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.org.datanucleus.store.query.Queryorg.datanucleus.store.query.Queryorg.datanucleus.store.query.QueryvoidprintInformation(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) booleanvoidvalidateSchemaForClasses(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, unmanageClassMethods inherited from class org.datanucleus.properties.PropertyStore
getFrequentProperties, hasPropertyNotNull, setPropertyInternalMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.datanucleus.store.StoreManager
getConnectionDriverName, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionURL, getConnectionUserName, transactionCommitted, transactionRolledBack, transactionStarted
-
Field Details
-
METADATA_NONDURABLE_REQUIRES_TABLE
- See Also:
-
dba
Adapter for the datastore being used. -
identifierFactory
Factory for identifiers for this datastore. -
catalogName
Default catalog name for the datastore. -
schemaName
Default schema name for the datastore. -
mappingManager
Manager for the mapping between Java and datastore types. -
insertedDatastoreClassByStateManager
protected Map<org.datanucleus.state.DNStateManager, DatastoreClass> insertedDatastoreClassByStateManagerMap of DatastoreClass keyed by StateManager, for objects currently being inserted. Defines to what level an object is inserted in the datastore. -
schemaLock
Lock object aimed at providing a lock on the schema definition managed here, preventing reads while it is being updated etc. -
sqlController
Controller for SQL executed on this store. -
expressionFactory
Factory for expressions using the generic query SQL mechanism. -
dateTimezoneCalendar
Calendar for this datastore. -
classAdder
The active class adder transaction, if any. Some RDBMSManager methods are called recursively in the course of adding new classes. This field allows such methods to coordinate with the active ClassAdder transaction. Write access is controlled via the "lock" object. -
ddlWriter
Writer for use when this RDBMSManager is configured to write DDL. -
completeDDL
private boolean completeDDLFlag for when generating schema as DDL and wanting complete DDL (as opposed to upgrade DDL). -
writtenDdlStatements
-
schemaCallbacks
State variable for schema generation of the callback information to be processed. TODO Move to ClassTable. -
backingStoreByMemberName
-
performingDeleteSchemaForClasses
boolean performingDeleteSchemaForClasses
-
-
Constructor Details
-
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 Details
-
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
Accessor for the factory for creating identifiers (table/column names etc).- Returns:
- Identifier factory
-
getDatastoreAdapter
Gets the DatastoreAdapter to use for this store.- Returns:
- Returns the DatastoreAdapter
-
getMappingManager
Gets the MappingManager to use for this store.- Returns:
- Returns the MappingManager.
-
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
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
Returns the primary datastore table serving as backing for the given class. If the class is not yet known to the store manager,manageClasses(ClassLoaderResolver, 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
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
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
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
- Specified by:
getNativeQueryLanguagein interfaceorg.datanucleus.store.StoreManager
-
getSupportedQueryLanguages
- Specified by:
getSupportedQueryLanguagesin interfaceorg.datanucleus.store.StoreManager- Overrides:
getSupportedQueryLanguagesin classorg.datanucleus.store.AbstractStoreManager
-
supportsQueryLanguage
- 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
-
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
Accessor for the SQL controller.- Returns:
- The SQL controller
-
getSQLExpressionFactory
Accessor for the SQL expression factory to use when generating SQL statements.- Returns:
- SQL expression factory
-
initialiseSchema
private void initialiseSchema(Connection conn, org.datanucleus.ClassLoaderResolver clr) throws Exception Initialises the schema name for the datastore, and (optionally) the schema table.- Parameters:
conn- A connection to the databaseclr- ClassLoader resolver- Throws:
Exception
-
clearSchemaData
private void clearSchemaData()Clears all knowledge of tables, cached requests, metadata, etc and resets the store manager to its initial state. -
getDefaultCatalogName
- Specified by:
getDefaultCatalogNamein interfaceorg.datanucleus.store.StoreManager
-
getDefaultSchemaName
- Specified by:
getDefaultSchemaNamein interfaceorg.datanucleus.store.StoreManager
-
getDatastoreDate
Get the date/time of the datastore.- Specified by:
getDatastoreDatein interfaceorg.datanucleus.store.StoreManager- Returns:
- Date/time of the datastore
-
manageClasses
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
-
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
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
When we are in SchemaTool DDL mode, add a new DDL statement.- Parameters:
stmt- The statement
-
validateTable
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
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
-
getTableForStrategy
private DatastoreClass getTableForStrategy(org.datanucleus.metadata.AbstractClassMetaData cmd, int fieldNumber, org.datanucleus.ClassLoaderResolver clr) -
supportsValueGenerationStrategy
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
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
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
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
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
- Specified by:
executeScriptin interfaceorg.datanucleus.store.schema.SchemaScriptAwareStoreManager
-
getSupportedOptions
- 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
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
-
createDatabase
- Specified by:
createDatabasein interfaceorg.datanucleus.store.schema.SchemaAwareStoreManager
-
deleteDatabase
- Specified by:
deleteDatabasein interfaceorg.datanucleus.store.schema.SchemaAwareStoreManager
-
createSchemaForClasses
- Specified by:
createSchemaForClassesin interfaceorg.datanucleus.store.schema.SchemaAwareStoreManager
-
createSchemaSequences
protected void createSchemaSequences(Set<String> classNames, org.datanucleus.ClassLoaderResolver clr, FileWriter ddlWriter) -
addSequenceTableForMetaData
-
addSequenceForMetaData
protected void addSequenceForMetaData(org.datanucleus.metadata.MetaData md, String seq, org.datanucleus.ClassLoaderResolver clr, Set<String> sequencesGenerated, FileWriter ddlWriter) -
deleteSchemaForClasses
- Specified by:
deleteSchemaForClassesin interfaceorg.datanucleus.store.schema.SchemaAwareStoreManager
-
validateSchemaForClasses
- Specified by:
validateSchemaForClassesin interfaceorg.datanucleus.store.schema.SchemaAwareStoreManager
-