Java Doc for StoreManager.java in  » Database-ORM » TJDO » com » triactive » jdo » store » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » TJDO » com.triactive.jdo.store 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.triactive.jdo.store.StoreManager

StoreManager
public class StoreManager implements SchemaManager(Code)
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:

  • Creating and/or validating database tables according to the persistent classes being accessed by the application.
  • Serving as the primary intermediary between StateManagers and the database (implements insert(), fetch(), update(), delete()).
  • Managing TJDO's schema table (JDO_TABLE).
  • Serving as the base Extent and Query factory.
  • Providing cached access to JDBC database metadata.
  • Resolving SQL identifier macros to actual SQL identifiers.

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.
author:
   Mike Martin
version:
   $Revision: 1.18 $




Constructor Summary
 StoreManager(PersistenceManagerFactoryImpl pmf, String userName, String password)
     Constructs a new StoreManager. On successful return the new StoreManager 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.

To avoid creating unnecessary redundant StoreManagers, new StoreManagers should always be obtained from the StoreManagerFactory , rather than constructed directly.
Parameters:
  pmf - The corresponding PersistenceManagerFactory.


Method Summary
public  voidaddClasses(Class[] classes)
     Adds the given persistence-capable classes to the store manager's set of active classes ready for persistence.
public  voiddelete(StateManager sm)
     Deletes a persistent object from the database.
public  voiddropAllTables()
    
public  voiddropTablesFor(Class[] classes)
    
public  voidfetch(StateManager sm, int fieldNumbers)
     Fetches a persistent object from the database.
public  ClassBaseTablegetClassBaseTable(Class c)
     Returns the primary table serving as backing for the given class. If the class is not yet known to the store manager, StoreManager.addClasses is called to add it.

This method is functionally equivalent to StoreManager.getTable(Class) except that it will only return base tables (not views).
Parameters:
  c - The class whose table is be returned.

 ListgetColumnInfo(SQLIdentifier tableName, Connection conn)
     Returns the column info for a database table.
public  DatabaseAdaptergetDatabaseAdapter()
     Returns the database adapter used by this store manager.
 DeleteRequestgetDeleteRequest(ClassBaseTable cbt)
     Returns a request object that will delete a row from the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table from which to delete.
public  ExtentgetExtent(PersistenceManager pm, Class c, boolean subclasses)
    
 FetchRequestgetFetchRequest(ClassBaseTable cbt, int[] fieldNumbers)
     Returns a request object that will fetch a row from the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table from which to fetch.
Parameters:
  fieldNumbers - The field numbers corresponding to the columns to befetched.
 ListgetForeignKeyInfo(SQLIdentifier tableName, Connection conn)
     Returns the foreign key info for a database table.
 InsertRequestgetInsertRequest(ClassBaseTable cbt)
     Returns a request object that will insert a row in the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table into which to insert.
public  StringgetJavaName(int tableID)
     Returns the Java name of the JDO table having the given table ID. Returns null if no such table exists in the schema.

If the table is not (yet) known to the store manager, this method does not initialize it.
Parameters:
  tableID - The table ID of the table to be returned.

 LookupRequestgetLookupRequest(ClassBaseTable cbt)
     Returns a request object that will lookup a row in the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table in which to lookup.
 intgetNextOIDHiValue(int classID)
     Returns the next OID high-order value for IDs of the given class.
Parameters:
  classID - The class ID number of the class.
public  QuerygetQuery(PersistenceManager pm, Object query)
    
public  QuerygetQuery(String language, PersistenceManager pm, Object query)
    
public  StringgetSchemaName()
    
public synchronized  JDOTablegetTable(SQLIdentifier name)
     Returns the JDO table having the given SQL name, if any. Returns null if no such table is (yet) known to the store manager.
Parameters:
  name - The name of the table.
public synchronized  JDOTablegetTable(int tableID)
     Returns the JDO table having the given table ID. Returns null if no such table is (yet) known to the store manager.
Parameters:
  tableID - The table ID of the table to be returned.
synchronized  JDOTablegetTable(MetaData md)
     Returns the JDO table having the given metadata, if any. Returns null if no such table is (yet) known to the store manager.
Parameters:
  md - The metadata for the table.
public  ClassTablegetTable(Class c)
     Returns the primary table serving as backing for the given class. If the class is not yet known to the store manager, StoreManager.addClasses is called to add it.
Parameters:
  c - The class whose table is be returned.
public  intgetTableType(SQLIdentifier tableName, Connection conn)
     Returns the type of a database table.
Parameters:
  tableName - The name of the table (or view).
Parameters:
  conn - A JDBC connection to the database.
 UpdateRequestgetUpdateRequest(ClassBaseTable cbt, int[] fieldNumbers)
     Returns a request object that will update a row in the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table in which to update.
Parameters:
  fieldNumbers - The field numbers corresponding to the columns to beupdated.
public  voidinsert(StateManager sm)
     Inserts a persistent object into the database.
public  voidlogSQLWarnings(SQLWarning warning)
     Logs SQL warnings to the common log.
public  voidlogSQLWarnings(Connection conn)
    
public  voidlogSQLWarnings(Statement stmt)
    
public  voidlogSQLWarnings(ResultSet rs)
    
public  voidlookup(StateManager sm)
     Confirms that a persistent object exists in the database.
synchronized  MapTablenewMapTable(ClassBaseTable cbt, FieldMetaData fmd)
     Called by Mapping objects in the midst of StoreManager.addClasses() to request the creation of a map table.
public  ObjectnewObjectID(Class c)
     Returns a new, unique ID for an object of the given class.
Parameters:
  c - The class of the object.
synchronized  SetTablenewSetTable(ClassBaseTable cbt, FieldMetaData fmd)
     Called by Mapping objects in the midst of StoreManager.addClasses() to request the creation of a set table.
public synchronized  voidreset()
     Clears all knowledge of tables, cached requests, metadata, etc and resets the store manager to its initial state.
public  voidresolveIdentifierMacro(MacroString.IdentifierMacro im)
     Resolves an identifier macro.
public  booleantableExists(SQLIdentifier tableName, Connection conn)
     Tests if a database table exists.
Parameters:
  tableName - The name of the table (or view).
Parameters:
  conn - A JDBC connection to the database.
public  voidupdate(StateManager sm, int fieldNumbers)
     Updates a persistent object in the database.


Constructor Detail
StoreManager
StoreManager(PersistenceManagerFactoryImpl pmf, String userName, String password)(Code)
Constructs a new StoreManager. On successful return the new StoreManager 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.

To avoid creating unnecessary redundant StoreManagers, new StoreManagers should always be obtained from the StoreManagerFactory , rather than constructed directly.
Parameters:
  pmf - The corresponding PersistenceManagerFactory. This factory'snon-transactional data source will be used to get databaseconnections as needed to perform management functions.
Parameters:
  userName - The database user name.
Parameters:
  password - The database user's password.
exception:
  JDODataStoreException - If the database could not be accessed or the name of the schemacould not be determined.
See Also:   StoreManagerFactory





Method Detail
addClasses
public void addClasses(Class[] classes)(Code)
Adds the given persistence-capable classes to the store manager's set of active classes ready for persistence. The act of adding a class to the store manager causes any necessary database objects (tables, views, constraints, indexes, etc.) to be created.

Other StoreManager methods may cause classes to be added as a side effect.
Parameters:
  classes - The class(es) to be added.




delete
public void delete(StateManager sm)(Code)
Deletes a persistent object from the database.
Parameters:
  sm - The state manager of the object to be deleted.



dropAllTables
public void dropAllTables()(Code)



dropTablesFor
public void dropTablesFor(Class[] classes)(Code)



fetch
public void fetch(StateManager sm, int fieldNumbers)(Code)
Fetches a persistent object from the database.
Parameters:
  sm - The state manager of the object to be fetched.
Parameters:
  fieldNumbers - The numbers of the fields to be fetched.



getClassBaseTable
public ClassBaseTable getClassBaseTable(Class c)(Code)
Returns the primary table serving as backing for the given class. If the class is not yet known to the store manager, StoreManager.addClasses is called to add it.

This method is functionally equivalent to StoreManager.getTable(Class) except that it will only return base tables (not views).
Parameters:
  c - The class whose table is be returned. The corresponding class table.
exception:
  NoExtentException - If the given class is not persistence-capable.
exception:
  ViewNotSupportedException - If the given class is backed by a view.




getColumnInfo
List getColumnInfo(SQLIdentifier tableName, Connection conn) throws SQLException(Code)
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:
  tableName - The name of the table (or view).
Parameters:
  conn - A JDBC connection to the database. A list of ColumnInfo objects describing the columns of thetable. The list is in the same order as was supplied bygetColumns(). If no column info is found for the given table,an empty list is returned.
See Also:   ColumnInfo




getDatabaseAdapter
public DatabaseAdapter getDatabaseAdapter()(Code)
Returns the database adapter used by this store manager. The database adapter used by this store manager.



getDeleteRequest
DeleteRequest getDeleteRequest(ClassBaseTable cbt)(Code)
Returns a request object that will delete a row from the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table from which to delete. A deletion request object.



getExtent
public Extent getExtent(PersistenceManager pm, Class c, boolean subclasses)(Code)



getFetchRequest
FetchRequest getFetchRequest(ClassBaseTable cbt, int[] fieldNumbers)(Code)
Returns a request object that will fetch a row from the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table from which to fetch.
Parameters:
  fieldNumbers - The field numbers corresponding to the columns to befetched. Field numbers whose columns exist insupertables will be ignored. A fetch request object.



getForeignKeyInfo
List getForeignKeyInfo(SQLIdentifier tableName, Connection conn) throws SQLException(Code)
Returns the foreign key info for a database table. This should be used instead of making direct calls to DatabaseMetaData.getImportedKeys() or DatabaseMetaData.getExportedKeys().
Parameters:
  tableName - The name of the table (or view).
Parameters:
  conn - A JDBC connection to the database.A list of ForeignKeyInfo objects describing the columns of thetable's foreign keys.The list is in the same order as was supplied by get??portedKeys().If no column info is found for the given table, an empty list isreturned.
See Also:   ForeignKeyInfo



getInsertRequest
InsertRequest getInsertRequest(ClassBaseTable cbt)(Code)
Returns a request object that will insert a row in the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table into which to insert. An insertion request object.



getJavaName
public String getJavaName(int tableID)(Code)
Returns the Java name of the JDO table having the given table ID. Returns null if no such table exists in the schema.

If the table is not (yet) known to the store manager, this method does not initialize it.
Parameters:
  tableID - The table ID of the table to be returned. The corresponding Java name, or null.




getLookupRequest
LookupRequest getLookupRequest(ClassBaseTable cbt)(Code)
Returns a request object that will lookup a row in the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table in which to lookup. A lookup request object.



getNextOIDHiValue
int getNextOIDHiValue(int classID)(Code)
Returns the next OID high-order value for IDs of the given class.
Parameters:
  classID - The class ID number of the class. The next high-order OID value.
exception:
  JDODataStoreException - If an error occurs in accessing or updating the schema table.



getQuery
public Query getQuery(PersistenceManager pm, Object query)(Code)



getQuery
public Query getQuery(String language, PersistenceManager pm, Object query)(Code)



getSchemaName
public String getSchemaName()(Code)



getTable
public synchronized JDOTable getTable(SQLIdentifier name)(Code)
Returns the JDO table having the given SQL name, if any. Returns null if no such table is (yet) known to the store manager.
Parameters:
  name - The name of the table. The corresponding JDO table, or null.



getTable
public synchronized JDOTable getTable(int tableID)(Code)
Returns the JDO table having the given table ID. Returns null if no such table is (yet) known to the store manager.
Parameters:
  tableID - The table ID of the table to be returned. The corresponding JDO table, or null.



getTable
synchronized JDOTable getTable(MetaData md)(Code)
Returns the JDO table having the given metadata, if any. Returns null if no such table is (yet) known to the store manager.
Parameters:
  md - The metadata for the table. The corresponding JDO table, or null.



getTable
public ClassTable getTable(Class c)(Code)
Returns the primary table serving as backing for the given class. If the class is not yet known to the store manager, StoreManager.addClasses is called to add it.
Parameters:
  c - The class whose table is be returned. The corresponding class table.
exception:
  NoExtentException - If the given class is not persistence-capable.



getTableType
public int getTableType(SQLIdentifier tableName, Connection conn) throws SQLException(Code)
Returns the type of a database table.
Parameters:
  tableName - The name of the table (or view).
Parameters:
  conn - A JDBC connection to the database. one of the TABLE_TYPE_* values from Table.
See Also:   Table



getUpdateRequest
UpdateRequest getUpdateRequest(ClassBaseTable cbt, int[] fieldNumbers)(Code)
Returns a request object that will update a row in the given table. The store manager will cache the request object for re-use by subsequent requests to the same table.
Parameters:
  cbt - The table in which to update.
Parameters:
  fieldNumbers - The field numbers corresponding to the columns to beupdated. Field numbers whose columns exist insupertables will be ignored. An update request object.



insert
public void insert(StateManager sm)(Code)
Inserts a persistent object into the database.
Parameters:
  sm - The state manager of the object to be inserted.



logSQLWarnings
public void logSQLWarnings(SQLWarning warning)(Code)
Logs SQL warnings to the common log. Should be called after any operation on a JDBC Statement or ResultSet object as:
 storeMgr.logSQLWarnings(obj.getWarnings());
 
If any warnings were generated, the entire list of them are logged to System.err.
Parameters:
  warning - the value returned from getWarnings().



logSQLWarnings
public void logSQLWarnings(Connection conn)(Code)



logSQLWarnings
public void logSQLWarnings(Statement stmt)(Code)



logSQLWarnings
public void logSQLWarnings(ResultSet rs)(Code)



lookup
public void lookup(StateManager sm)(Code)
Confirms that a persistent object exists in the database.
Parameters:
  sm - The state manager of the object to be fetched.



newMapTable
synchronized MapTable newMapTable(ClassBaseTable cbt, FieldMetaData fmd)(Code)
Called by Mapping objects in the midst of StoreManager.addClasses() to request the creation of a map table.
Parameters:
  cbt - The base table for the class containing the map.
Parameters:
  fmd - The field metadata describing the map field.



newObjectID
public Object newObjectID(Class c)(Code)
Returns a new, unique ID for an object of the given class.
Parameters:
  c - The class of the object. A new object ID.



newSetTable
synchronized SetTable newSetTable(ClassBaseTable cbt, FieldMetaData fmd)(Code)
Called by Mapping objects in the midst of StoreManager.addClasses() to request the creation of a set table.
Parameters:
  cbt - The base table for the class containing the set.
Parameters:
  fmd - The field metadata describing the set field.



reset
public synchronized void reset()(Code)
Clears all knowledge of tables, cached requests, metadata, etc and resets the store manager to its initial state.



resolveIdentifierMacro
public void resolveIdentifierMacro(MacroString.IdentifierMacro im)(Code)
Resolves an identifier macro. The public fields clazz, 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.



tableExists
public boolean tableExists(SQLIdentifier tableName, Connection conn) throws SQLException(Code)
Tests if a database table exists.
Parameters:
  tableName - The name of the table (or view).
Parameters:
  conn - A JDBC connection to the database. true if the table exists in the database,false otherwise.



update
public void update(StateManager sm, int fieldNumbers)(Code)
Updates a persistent object in the database.
Parameters:
  sm - The state manager of the object to be updated.
Parameters:
  fieldNumbers - The numbers of the fields to be updated.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.