|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.triactive.jdo.store.StoreManager
public class StoreManager
Manages the contents of a data store (aka database schema) on behalf of a particular PersistenceManagerFactory and all its persistent instances.
The store manager's responsibilities include:
A store manager's knowledge of its schema's contents is not necessarily complete. It is aware of only those tables whose classes have somehow been accessed, directly or indirectly, by the application during the life of the store manager object.
Constructor Summary | |
---|---|
StoreManager(PersistenceManagerFactoryImpl pmf,
java.lang.String userName,
java.lang.String password)
Constructs a new StoreManager. |
Method Summary | |
---|---|
void |
addClasses(java.lang.Class[] classes)
Adds the given persistence-capable classes to the store manager's set of active classes ready for persistence. |
void |
delete(StateManager sm)
Deletes a persistent object from the database. |
void |
dropAllTables()
Drops all tables in the schema. |
void |
dropTablesFor(java.lang.Class[] classes)
Removes from the schema any existing database tables used in persisting the given PersistenceCapable class(es). |
void |
fetch(StateManager sm,
int[] fieldNumbers)
Fetches a persistent object from the database. |
ClassBaseTable |
getClassBaseTable(java.lang.Class c)
Returns the primary table serving as backing for the given class. |
java.lang.Class |
getClassForObjectID(java.lang.Object id)
Returns the class corresponding to the given object ID. |
(package private) java.util.List |
getColumnInfo(SQLIdentifier tableName,
java.sql.Connection conn)
Returns the column info for a database table. |
DatabaseAdapter |
getDatabaseAdapter()
Returns the database adapter used by this store manager. |
(package private) DeleteRequest |
getDeleteRequest(ClassBaseTable cbt)
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)
|
(package private) FetchRequest |
getFetchRequest(ClassBaseTable cbt,
int[] fieldNumbers)
Returns a request object that will fetch a row from the given table. |
(package private) java.util.List |
getForeignKeyInfo(SQLIdentifier tableName,
java.sql.Connection conn)
Returns the foreign key info for a database table. |
(package private) InsertRequest |
getInsertRequest(ClassBaseTable cbt)
Returns a request object that will insert a row in the given table. |
(package private) int |
getNextOIDHiValue(int classID)
Returns the next OID high-order value for IDs of the given class. |
Query |
getQuery(PersistenceManager pm,
java.lang.Object query)
|
Query |
getQuery(java.lang.String language,
PersistenceManager pm,
java.lang.Object query)
|
java.lang.String |
getSchemaName()
Returns the name of the database schema. |
(package private) ClassTable |
getTable(java.lang.Class c)
Returns the primary table serving as backing for the given class. |
(package private) JDOTable |
getTable(MetaData md)
Returns the JDO table having the given metadata, if any. |
JDOTable |
getTable(SQLIdentifier name)
Returns the JDO table having the given SQL name, if any. |
int |
getTableType(SQLIdentifier tableName,
java.sql.Connection conn)
Returns the type of a database table. |
(package private) UpdateRequest |
getUpdateRequest(ClassBaseTable cbt,
int[] fieldNumbers)
Returns a request object that will update a row in the given table. |
void |
insert(StateManager sm)
Inserts a persistent object into the database. |
void |
logSQLWarnings(java.sql.Connection conn)
|
void |
logSQLWarnings(java.sql.ResultSet rs)
|
void |
logSQLWarnings(java.sql.SQLWarning warning)
Logs SQL warnings to the common log. |
void |
logSQLWarnings(java.sql.Statement stmt)
|
(package private) MapTable |
newMapTable(ClassBaseTable cbt,
FieldMetaData fmd)
Called by Mapping objects in the midst of StoreManager.addClasses() to request the creation of a map table. |
java.lang.Object |
newObjectID(java.lang.Class c)
Returns a new, unique ID for an object of the given class. |
(package private) SetTable |
newSetTable(ClassBaseTable cbt,
FieldMetaData fmd)
Called by Mapping objects in the midst of StoreManager.addClasses() to request the creation of a set table. |
void |
reset()
Clears all knowledge of tables, cached requests, metadata, etc and resets the store manager to its initial state. |
void |
resolveIdentifierMacro(MacroString.IdentifierMacro im)
Resolves an identifier macro. |
boolean |
tableExists(SQLIdentifier tableName,
java.sql.Connection conn)
Tests if a database table exists. |
void |
update(StateManager sm,
int[] fieldNumbers)
Updates a persistent object in the database. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
StoreManager(PersistenceManagerFactoryImpl pmf, java.lang.String userName, java.lang.String password)
To avoid creating unnecessary redundant StoreManagers, new StoreManagers
should always be obtained from the StoreManagerFactory
, rather
than constructed directly.
pmf
- 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 reset()
reset
in interface SchemaManager
public DatabaseAdapter getDatabaseAdapter()
public java.lang.String getSchemaName()
SchemaManager
getSchemaName
in interface SchemaManager
null
if the
DBMS does not support the concept of schemas.public void logSQLWarnings(java.sql.SQLWarning warning)
If any warnings were generated, the entire list of them are logged to System.err.storeMgr.logSQLWarnings(obj.getWarnings());
warning
- the value returned from getWarnings().public void logSQLWarnings(java.sql.Connection conn)
public void logSQLWarnings(java.sql.Statement stmt)
public void logSQLWarnings(java.sql.ResultSet rs)
public void addClasses(java.lang.Class[] classes)
Other StoreManager methods may cause classes to be added as a side effect.
addClasses
in interface SchemaManager
classes
- The class(es) to be added.SetTable newSetTable(ClassBaseTable cbt, FieldMetaData fmd)
cbt
- The base table for the class containing the set.fmd
- The field metadata describing the set field.MapTable newMapTable(ClassBaseTable cbt, FieldMetaData fmd)
cbt
- The base table for the class containing the map.fmd
- The field metadata describing the map field.public void dropTablesFor(java.lang.Class[] classes)
SchemaManager
This method will fail if the relevant tables are depended upon by others used for classes that are not being removed. In case of failure, it is unspecified whether or not any tables were actually removed.
After dropping tables this method performs an implicit SchemaManager.reset()
.
dropTablesFor
in interface SchemaManager
classes
- The class(es) whose tables are to be removed.public void dropAllTables()
SchemaManager
After dropping tables this method performs an implicit SchemaManager.reset()
.
dropAllTables
in interface SchemaManager
public JDOTable getTable(SQLIdentifier name)
null
if no such table is (yet) known to the store
manager.
name
- The name of the table.
null
.JDOTable getTable(MetaData md)
null
if no such table is (yet) known to the store
manager.
md
- The metadata for the table.
null
.ClassTable getTable(java.lang.Class c)
addClasses(java.lang.Class[])
is called to add it.
c
- The class whose table is be returned.
NoExtentException
- If the given class is not persistence-capable.public ClassBaseTable getClassBaseTable(java.lang.Class c)
addClasses(java.lang.Class[])
is called to add it.
This method is functionally equivalent to getTable(Class)
except that it will only return base tables (not views).
c
- The class whose table is be returned.
NoExtentException
- If the given class is not persistence-capable.
ViewNotSupportedException
- If the given class is backed by a view.public java.lang.Class getClassForObjectID(java.lang.Object id)
id
- The JDO identity of some object.
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)
public Query getQuery(PersistenceManager pm, java.lang.Object query)
public Query getQuery(java.lang.String language, PersistenceManager pm, java.lang.Object query)
public java.lang.Object newObjectID(java.lang.Class c)
c
- The class of the object.
int getNextOIDHiValue(int classID)
classID
- The class ID number of the class.
javax.jdo.JDODataStoreException
- If an error occurs in accessing or updating the schema table.public void insert(StateManager sm)
sm
- The state manager of the object to be inserted.public void fetch(StateManager sm, int[] fieldNumbers)
sm
- The state manager of the object to be fetched.fieldNumbers
- The numbers of the fields to be fetched.public void update(StateManager sm, int[] fieldNumbers)
sm
- The state manager of the object to be updated.fieldNumbers
- The numbers of the fields to be updated.public void delete(StateManager sm)
sm
- The state manager of the object to be deleted.InsertRequest getInsertRequest(ClassBaseTable cbt)
cbt
- The table into which to insert.
FetchRequest getFetchRequest(ClassBaseTable cbt, int[] fieldNumbers)
cbt
- The table from which to fetch.fieldNumbers
- The field numbers corresponding to the columns to be
fetched. Field numbers whose columns exist in
supertables will be ignored.
UpdateRequest getUpdateRequest(ClassBaseTable cbt, int[] fieldNumbers)
cbt
- The table in which to update.fieldNumbers
- The field numbers corresponding to the columns to be
updated. Field numbers whose columns exist in
supertables will be ignored.
DeleteRequest getDeleteRequest(ClassBaseTable cbt)
cbt
- The table from which to delete.
public int getTableType(SQLIdentifier tableName, java.sql.Connection conn) throws java.sql.SQLException
tableName
- The name of the table (or view).conn
- A JDBC connection to the database.
Table
.
java.sql.SQLException
Table
java.util.List getColumnInfo(SQLIdentifier tableName, 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).
tableName
- The name of the table (or view).conn
- A JDBC connection to the database.
java.sql.SQLException
ColumnInfo
java.util.List getForeignKeyInfo(SQLIdentifier tableName, java.sql.Connection conn) throws java.sql.SQLException
tableName
- The name of the table (or view).conn
- A JDBC connection to the database.
java.sql.SQLException
ForeignKeyInfo
public boolean tableExists(SQLIdentifier tableName, java.sql.Connection conn) throws java.sql.SQLException
tableName
- The name of the table (or view).conn
- A JDBC connection to the database.
java.sql.SQLException
public void resolveIdentifierMacro(MacroString.IdentifierMacro im)
im
- The macro to resolve.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |