|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jpox.store.StoreManager
org.jpox.store.rdbms.RDBMSManager
Manages the contents of a database schema on behalf of a particular PersistenceManagerFactory and all of its persistent instances.
The RDBMS manager's responsibilities extend those for Storemanager to add :
Field Summary | |
protected static Localiser |
LOCALISER_RDBMS
Localiser for messages. |
Fields inherited from class org.jpox.store.StoreManager |
autoCreateColumns, autoCreateConstraints, autoCreateTables, autoCreateWarnOnError, checkExistTablesOrViews, dba, defaultPoidGeneratorClass, dictionary, ds, dsNonTx, fixedSchema, identifierFactory, LOCALISER, password, pmfContext, poidManager, readOnlySchema, starter, starterInitialised, storeDataByAppIdClass, storeDataByClass, userName, validateColumns, validateConstraints, validateTables |
Constructor Summary | |
RDBMSManager(ClassLoaderResolver clr,
AbstractPersistenceManagerFactory pmf,
java.lang.String userName,
java.lang.String password)
Constructs a new RDBMSManager. |
Method Summary | |
void |
addClass(java.lang.String className,
ClassLoaderResolver clr)
Method to add a (PersistenceCapable) class to the store manager's set of supported classes. |
void |
addClasses(java.lang.String[] classNames,
ClassLoaderResolver clr)
Method to add several (PersistenceCapable) classes to the store manager's set of supported classes. |
void |
close()
Release of resources |
void |
closeConnection(java.sql.Connection conn)
Utility to close a Connection for the Datastore. |
ArrayStore |
getBackingStoreForArray(AbstractPropertyMetaData fmd,
DatastoreObject datastoreTable,
ClassLoaderResolver clr)
Method to return a backing store for an array, consistent with this store and the instantiated type. |
CollectionStore |
getBackingStoreForCollection(java.lang.Class instantiatedType,
AbstractPropertyMetaData fmd,
DatastoreObject datastoreTable,
ClassLoaderResolver clr)
Method to return a backing store for a Collection, consistent with this store and the instantiated type. |
MapStore |
getBackingStoreForMap(AbstractPropertyMetaData fmd,
DatastoreObject datastoreTable,
ClassLoaderResolver clr)
Method to return a backing store for a Map, consistent with this store and the instantiated type. |
java.lang.String |
getCatalogName()
Accessor for the RDBMS catalog name. |
java.lang.String |
getClassNameForObjectID(java.lang.Object id,
ClassLoaderResolver clr,
PersistenceManager pm)
Returns the class corresponding to the given object JDO ID. |
java.util.List |
getColumnInfo(java.lang.String schemaNamePattern,
java.lang.String tableNamePattern)
Returns the column info for a database schema. |
ColumnInfo |
getColumnInfoForColumnName(Table table,
java.sql.Connection conn,
DatastoreIdentifier column)
Returns the column info for a column name. |
java.util.List |
getColumnInfoForTable(Table table,
java.sql.Connection conn)
Returns the column info for a database table. |
java.sql.Connection |
getConnection(int isolation_level)
Utility to return a Connection not associated to the current transaction. |
DeleteRequest |
getDeleteRequest(DatastoreClass table,
java.lang.Class cls,
ClassLoaderResolver clr)
Returns a request object that will delete a row from the given table. |
javax.jdo.Extent |
getExtent(PersistenceManager pm,
java.lang.Class c,
boolean subclasses)
Accessor for an Extent for a class, and its subclasses. |
FetchRequest |
getFetchRequest(DatastoreClass table,
AbstractPropertyMetaData[] fieldMetaData,
java.lang.Class cls,
ClassLoaderResolver clr)
Returns a request object that will fetch a row from the given table. |
FetchStatement |
getFetchStatement(DatastoreContainerObject table)
Method to create a new fetch statement for the passed table. |
InsertRequest |
getInsertRequest(DatastoreClass table,
java.lang.Class cls,
ClassLoaderResolver clr)
Returns a request object that will insert a row in the given table. |
LocateRequest |
getLocateRequest(DatastoreClass table,
java.lang.String className)
Returns a request object that will locate a row from the given table. |
java.lang.String |
getSchemaName()
Accessor for the RDBMS schema name. |
java.sql.PreparedStatement |
getStatement(java.sql.Connection conn,
java.lang.String stmtText,
boolean applyTimeout)
Convenience method to create a new PreparedStatement. |
java.sql.PreparedStatement |
getStatement(java.sql.Connection conn,
java.lang.String stmtText,
boolean applyTimeout,
java.lang.String resultSetType,
java.lang.String resultSetConcurrency)
Convenience method to create a new PreparedStatement. |
java.lang.Object |
getStrategyValue(PersistenceManager pm,
DatastoreClass table,
AbstractClassMetaData cmd,
int absoluteFieldNumber,
IdentityStrategy strategy,
java.lang.String sequence,
ExtensionMetaData[] extensions)
Method to return the value for the specified strategy. |
java.util.List |
getTableInfo()
Returns the table info for a database schema. |
java.util.List |
getTableInfo(java.lang.String schemaNamePattern)
Returns the table info for a database schema. |
UpdateRequest |
getUpdateRequest(DatastoreClass table,
AbstractPropertyMetaData[] fieldMetaData,
java.lang.Class cls,
ClassLoaderResolver clr)
Returns a request object that will update a row in the given table. |
void |
invalidateColumnInfoForTable(Table table)
Method to invalidate the cached column info for a table. |
DatastoreContainerObject |
newJoinDatastoreContainerObject(AbstractPropertyMetaData fmd,
ClassLoaderResolver clr)
Called by (container) Mapping objects to request the creation of a DatastoreObject (table). |
java.lang.Object |
newObjectID(PersistenceManager pm,
java.lang.String className,
javax.jdo.spi.PersistenceCapable pc)
Returns a new, unique ID for an object of the given class. |
javax.jdo.Query |
newQuery(java.lang.String language,
PersistenceManager pm,
java.lang.Object query)
Method to generate a new query using the passed query as basis. |
void |
removeAllClasses(ClassLoaderResolver clr)
Utility to remove all classes that we are managing. |
void |
resolveIdentifierMacro(MacroString.IdentifierMacro im,
ClassLoaderResolver clr)
Resolves an identifier macro. |
boolean |
supportsQueryLanguage(java.lang.String language)
Accessor for whether this query language is supported. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final Localiser LOCALISER_RDBMS
Constructor Detail |
public RDBMSManager(ClassLoaderResolver clr, AbstractPersistenceManagerFactory pmf, java.lang.String userName, java.lang.String password)
To avoid creating unnecessary redundant RDBMSManagers, new RDBMSManagers
should always be obtained from the StoreManagerFactory
,
rather than constructed directly.
clr
- the ClassLoaderResolverpmf
- The corresponding PersistenceManagerFactory. This factory's
non-transactional data source will be used to get database
connections as needed to perform management functions.userName
- The database user name.password
- The database user's password.
javax.jdo.JDODataStoreException
- If the database could not be accessed or the name of the
schema could not be determined.StoreManagerFactory
Method Detail |
public void close()
close
in class StoreManager
public java.sql.Connection getConnection(int isolation_level) throws java.sql.SQLException
isolation_level
- The transaction isolation scheme to use e.g
Connection.TRANSACTION_NONE
java.sql.SQLException
public void closeConnection(java.sql.Connection conn) throws java.sql.SQLException
conn
- The Connection to the datastore
java.sql.SQLException
public java.sql.PreparedStatement getStatement(java.sql.Connection conn, java.lang.String stmtText, boolean applyTimeout) throws java.sql.SQLException
conn
- The Connection to use for the statementstmtText
- Statement textapplyTimeout
- Whether this query will apply any timeout (where specified)
java.sql.SQLException
- thrown if an error occurs creating the statementpublic java.sql.PreparedStatement getStatement(java.sql.Connection conn, java.lang.String stmtText, boolean applyTimeout, java.lang.String resultSetType, java.lang.String resultSetConcurrency) throws java.sql.SQLException
conn
- The Connection to use for the statementstmtText
- Statement textapplyTimeout
- Whether this query will apply any timeout (where specified)resultSetType
- Type of result setresultSetConcurrency
- Concurrency for the result set
java.sql.SQLException
- thrown if an error occurs creating the statementpublic java.lang.String getCatalogName()
public java.lang.String getSchemaName()
public void addClasses(java.lang.String[] classNames, ClassLoaderResolver clr)
addClasses
in class StoreManager
classNames
- Name of the class(es) to be added.clr
- The ClassLoaderResolverpublic void addClass(java.lang.String className, ClassLoaderResolver clr)
addClass
in class StoreManager
className
- Name of the class to be added.clr
- The ClassLoaderResolverpublic void removeAllClasses(ClassLoaderResolver clr)
removeAllClasses
in class StoreManager
clr
- The ClassLoaderResolverpublic FetchStatement getFetchStatement(DatastoreContainerObject table)
getFetchStatement
in class StoreManager
table
- The table to fetch from
public DatastoreContainerObject newJoinDatastoreContainerObject(AbstractPropertyMetaData fmd, ClassLoaderResolver clr)
newJoinDatastoreContainerObject
in class StoreManager
fmd
- The field metadata describing the field.clr
- The ClassLoaderResolver
public CollectionStore getBackingStoreForCollection(java.lang.Class instantiatedType, AbstractPropertyMetaData fmd, DatastoreObject datastoreTable, ClassLoaderResolver clr)
getBackingStoreForCollection
in class StoreManager
instantiatedType
- Type of the instantiated collectionfmd
- MetaData for the field that has this collectiondatastoreTable
- The datastore objectclr
- ClassLoader resolver
public MapStore getBackingStoreForMap(AbstractPropertyMetaData fmd, DatastoreObject datastoreTable, ClassLoaderResolver clr)
getBackingStoreForMap
in class StoreManager
fmd
- MetaData for the field that has this mapdatastoreTable
- The datastore objectclr
- ClassLoader resolver
public ArrayStore getBackingStoreForArray(AbstractPropertyMetaData fmd, DatastoreObject datastoreTable, ClassLoaderResolver clr)
getBackingStoreForArray
in class StoreManager
fmd
- MetaData for the field that has this arraydatastoreTable
- The datastore objectclr
- ClassLoader resolver
public java.lang.String getClassNameForObjectID(java.lang.Object id, ClassLoaderResolver clr, PersistenceManager pm)
getClassNameForObjectID
in class StoreManager
id
- The JDO identity of some object.clr
- ClassLoader resolverpm
- Persistence Manager (optional - to allow check in the datastore)
java.lang.ClassCastException
- If the type of ID is not recognized (
OID
or SCOID
).public javax.jdo.Extent getExtent(PersistenceManager pm, java.lang.Class c, boolean subclasses)
getExtent
in class StoreManager
pm
- The Persistence Managerc
- The (candidate) class to use for the Extentsubclasses
- Whether to include subclasses of 'c'
NoExtentException
- if an extent is not managed for the
specified classpublic boolean supportsQueryLanguage(java.lang.String language)
supportsQueryLanguage
in class StoreManager
language
- The language
StoreManager.supportsQueryLanguage(java.lang.String)
public javax.jdo.Query newQuery(java.lang.String language, PersistenceManager pm, java.lang.Object query)
newQuery
in class StoreManager
language
- The query languagepm
- The PMquery
- The query filter (String) or a previous Query
public java.lang.Object newObjectID(PersistenceManager pm, java.lang.String className, javax.jdo.spi.PersistenceCapable pc)
newObjectID
in class StoreManager
pm
- The PersistenceManagerclassName
- Name of the class of the object.pc
- The persistenceCapable object. Useful for AppID
public java.lang.Object getStrategyValue(PersistenceManager pm, DatastoreClass table, AbstractClassMetaData cmd, int absoluteFieldNumber, IdentityStrategy strategy, java.lang.String sequence, ExtensionMetaData[] extensions)
getStrategyValue
in class StoreManager
pm
- the PersistenceManager requesting an ID for the objecttable
- The datastore tablecmd
- AbstractClassMetaData for the class containing this fieldabsoluteFieldNumber
- Absolute number of the field (-1 means datastore identity field)strategy
- The strategy to use for defining the valuesequence
- Name of a sequence if the strategy is sequenceextensions
- Any extensions to control the value generation process.
For value-strategy tags this is in the field extension.
For datastore-identity tags this is in the datastore-identity extension.
javax.jdo.JDODataStoreException
- Thrown if an error occurs getting the valuepublic InsertRequest getInsertRequest(DatastoreClass table, java.lang.Class cls, ClassLoaderResolver clr)
table
- The table into which to insert.cls
- class of the object of the requestclr
- ClassLoader resolver
public FetchRequest getFetchRequest(DatastoreClass table, AbstractPropertyMetaData[] fieldMetaData, java.lang.Class cls, ClassLoaderResolver clr)
table
- The table from which to fetch.fieldMetaData
- MetaData for the fields corresponding to the columns
to be fetched.cls
- class of the object of the requestclr
- ClassLoader resolver
public UpdateRequest getUpdateRequest(DatastoreClass table, AbstractPropertyMetaData[] fieldMetaData, java.lang.Class cls, ClassLoaderResolver clr)
table
- The table in which to update.fieldMetaData
- The AbstractPropertyMetaData corresponding to the columns to be
updated. FieldMetaData whose columns exist in supertables will be
ignored.cls
- class of the object of the requestclr
- ClassLoader resolver
public LocateRequest getLocateRequest(DatastoreClass table, java.lang.String className)
table
- The table from which to locate.className
- the class name of the object of the request
public DeleteRequest getDeleteRequest(DatastoreClass table, java.lang.Class cls, ClassLoaderResolver clr)
table
- The table from which to delete.cls
- class of the object of the requestclr
- ClassLoader resolver
public ColumnInfo getColumnInfoForColumnName(Table table, java.sql.Connection conn, DatastoreIdentifier column) throws java.sql.SQLException
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).
table
- The table/viewconn
- JDBC connection to the database.column
- the column
java.sql.SQLException
ColumnInfo
public java.util.List getColumnInfoForTable(Table table, java.sql.Connection conn) throws java.sql.SQLException
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).
table
- The table/viewconn
- JDBC connection to the database.
java.sql.SQLException
ColumnInfo
public java.util.List getTableInfo() throws java.sql.SQLException
Where possible, this method loads and caches table info for more than just the table being requested, improving performance by reducing the overall number of calls made to DatabaseMetaData.getTables() (each of which usually results in one or more database queries).
java.sql.SQLException
TableInfo
public java.util.List getTableInfo(java.lang.String schemaNamePattern) throws java.sql.SQLException
Where possible, this method loads and caches table info for more than just the table being requested, improving performance by reducing the overall number of calls made to DatabaseMetaData.getTables() (each of which usually results in one or more database queries).
schemaNamePattern
- the schema name pattern
java.sql.SQLException
TableInfo
public java.util.List getColumnInfo(java.lang.String schemaNamePattern, java.lang.String tableNamePattern) throws java.sql.SQLException
Where possible, this method loads and caches table 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).
schemaNamePattern
- the schema name patterntableNamePattern
- the table name pattern
java.sql.SQLException
ColumnInfo
public void invalidateColumnInfoForTable(Table table)
table
- The tablepublic void resolveIdentifierMacro(MacroString.IdentifierMacro im, ClassLoaderResolver clr)
resolveIdentifierMacro
in class StoreManager
im
- The macro to resolve.clr
- The ClassLoaderResolver
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |