SolarMetric Kodo JDO 2.4.3 generated on March 27 2003

com.solarmetric.kodo.impl.jdbc.runtime
Class JDBCStoreManager

java.lang.Object
  |
  +--com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager
All Implemented Interfaces:
StoreManager

public class JDBCStoreManager
extends Object
implements StoreManager

StoreManager plugin for the common JDO runtime environent that uses JDBC to store persistent data in a relational data store.


Constructor Summary
JDBCStoreManager()
           
 
Method Summary
 boolean addSQLExecutionListener(SQLExecutionListener listener)
          Add a listener for all SQLExecution events.
 void begin()
          Begin a data store transaction.
 void beginOptimistic()
          Notification that an optimistic transaction has started.
 boolean checkVersion(StateManagerImpl sm)
          Determine whether the given StateManager is the same version as the datastore version.
 void commit()
          Commit the current data store transaction.
 Object copyDataStoreId(Object oid, ClassMetaData meta)
          Copy the given object id value.
 Object createFromResultSet(ClassMapping cm, SQLExecutionManager sqlem, ResultSet rs, FieldMetaData[] fmds, int index)
          Create an instance from the given result set; if the instance is already cached it will be returned.
protected  ResultList executeQuery(ClassMapping cm, SQLExecutionManager sqlem, PreparedStatement stmnt, boolean subs)
          Execute the given prepared statement loading instances through the given mapping.
protected  ResultList executeQuery(ObjectSelect sel, Class type, boolean subs)
          Load all matching objects for the given query.
 boolean exists(Object oid, ClassMetaData meta)
          Verify that the given instance exists in the data store.
 Collection flush(Collection states)
          Flush the given state manager collection to the datastore, returning a collection of user exceptions encountered during flushing.
 JDBCConfiguration getConfiguration()
          Return the configuration for this store.
 Connection getConnection()
          Returns a Connection to the data store.
 Connector getConnector()
          Returns a Connector, which can be used to obtain a Connection instance.
 Class getDataStoreIdClass(ClassMetaData meta)
          Return the class used by this StoreManager for datastore identity values.
 DBDictionary getDictionary()
          Obtain a DBDictionary that used this PersistenceManagerImpl's Connector.
 PersistenceManagerImpl getPersistenceManager()
          Return the PersistenceManager this StoreManager is owned by.
 JDBCPersistenceManagerFactory getPersistenceManagerFactory()
           
 SQLExecutionManager getSQLExecutionManager()
          Return a SQLExecutionManager for interaction with the database; if there is a transaction in progress the connection will be transactionally consistent.
 boolean initialize(StateManagerImpl sm, com.solarmetric.kodo.runtime.JDOState state, Object connection)
          Initialize the given StateManager.
 boolean isActive()
          Returns true if there is a data store transaction active.
 void load(StateManagerImpl sm, Object connection, BitSet fields, boolean setVersion)
          Load the given StateManager.
 Object newDataStoreId(ClassMetaData meta)
          Create a new unique datastore identity for the given type.
 Object newDataStoreId(String str, ClassMetaData meta)
          Create a new unique datastore identity for the given type from the given string.
 Extent newExtent(ClassMetaData meta, boolean subclasses)
          Return an extent of the given candidate class, optionally including subclasses.
 com.solarmetric.kodo.query.FilterExtensions newFilterExtensions()
          Return a FilterExtensions implementation for use in queries.
 Query newQuery(String language, Object copy)
          Return a query implementation suitable for this runtime.
 void release(SQLExecutionManager manager)
          Release the SQLExecutionManager if appropriate (i.e., if we do not have an active datastore transaction).
 void releaseConnection(Connection c)
          Releases the obtained Connection.
 boolean removeSQLExecutionListener(SQLExecutionListener listener)
          Remove a listener for all SQLExecution events.
 void rollback()
          Rollback the current data store transaction.
 void setPersistenceManager(PersistenceManagerImpl pm)
          Set the PersistenceManager this StoreManager is owned by.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCStoreManager

public JDBCStoreManager()
Method Detail

getPersistenceManager

public PersistenceManagerImpl getPersistenceManager()
Return the PersistenceManager this StoreManager is owned by.

setPersistenceManager

public void setPersistenceManager(PersistenceManagerImpl pm)
Set the PersistenceManager this StoreManager is owned by.
Specified by:
setPersistenceManager in interface StoreManager

getPersistenceManagerFactory

public JDBCPersistenceManagerFactory getPersistenceManagerFactory()

getConfiguration

public JDBCConfiguration getConfiguration()
Return the configuration for this store.

beginOptimistic

public void beginOptimistic()
Description copied from interface: StoreManager
Notification that an optimistic transaction has started. This method does not replace the StoreManager.begin() method, which will still be called when a true data store transaction should begin.
Specified by:
beginOptimistic in interface StoreManager

begin

public void begin()
Description copied from interface: StoreManager
Begin a data store transaction. If optimistic transactions are in use, this method will only be called when the user is ready to commit the transaction. At this time, the PersistenceManager will call this begin method, will store all modified data, and will call the commit method in succession, minimizing the length of the actual data store transaction. In this case, it is possible that the optimistic transaction does not have the latest versions of all instances (i.e. another transaction has modified the same instances and committed since the optimistic transaction started). On commit, an exception must be thrown on any attempt to overwrite data for an instance with an older version.
Specified by:
begin in interface StoreManager

commit

public void commit()
Description copied from interface: StoreManager
Commit the current data store transaction.
Specified by:
commit in interface StoreManager

rollback

public void rollback()
Description copied from interface: StoreManager
Rollback the current data store transaction.
Specified by:
rollback in interface StoreManager

exists

public boolean exists(Object oid,
                      ClassMetaData meta)
Description copied from interface: StoreManager
Verify that the given instance exists in the data store.
Specified by:
exists in interface StoreManager

checkVersion

public boolean checkVersion(StateManagerImpl sm)
Description copied from interface: StoreManager
Determine whether the given StateManager is the same version as the datastore version.
Specified by:
checkVersion in interface StoreManager
Following copied from interface: com.solarmetric.kodo.runtime.StoreManager
Parameters:
sm - the instance to check
Returns:
true if the instance is up-to-date, false otherwise

initialize

public boolean initialize(StateManagerImpl sm,
                          com.solarmetric.kodo.runtime.JDOState state,
                          Object connection)
Description copied from interface: StoreManager
Initialize the given StateManager. The oid of the StateManager will be set, and the meta field of the StateManager will be set to the class of the instance to load, or possibly one of its superclasses. Initialization involves first calling the StateManagerImpl#setPersistenceCapable method with a new instance of the correct type constructed with the JDOImplHelper#newInstance(Class,StateManager,Object) method (this will reset the meta field of the StateManager if the actual type was a subclass), then possibly loading any fields if desired. The version information for the StateManager should also be set via the StateManagerImpl.setVersion(java.lang.Object) method. If this method is called during a data store transaction, the instance should be locked.
Specified by:
initialize in interface StoreManager
Following copied from interface: com.solarmetric.kodo.runtime.StoreManager
Parameters:
sm - the instance to initialize
state - the JDO state to pass through to the state manager's initialize method
connection - the current connection information, or null if not given to the calling method of the persistence manager
Returns:
true if the matching instance exists in the data store, false otherwise

load

public void load(StateManagerImpl sm,
                 Object connection,
                 BitSet fields,
                 boolean setVersion)
Description copied from interface: StoreManager
Load the given StateManager. Note that any collection or map types loaded into the StateManager will be proxied with the correct type; therefore the StoreManager does not have to load the same concrete collection/map types as the instance declares. However, array types must be consistent with the array type stored by the PersistenceCapable instance. If this method is called during a data store transaction, the instance should be locked.
Specified by:
load in interface StoreManager
Following copied from interface: com.solarmetric.kodo.runtime.StoreManager
Parameters:
sm - the instance to load
connection - the current connection information, or null if not given to the calling method of the persistence manager
fields - the fields to load; the field corrsponding to the metadata field at each set bit position should be loaded; additional fields can be loaded if desired; attempting to load an additional field that has been dirtied will cause the load to be ignored; this bit set should not be modified
setVersion - if true, the version information should also be loaded from the db and set in the instance via the StateManagerImpl.setVersion(java.lang.Object) method

flush

public Collection flush(Collection states)
Description copied from interface: StoreManager
Flush the given state manager collection to the datastore, returning a collection of user exceptions encountered during flushing. The given state collection may include states that do not require data store action, such as persistent-clean instances. For datastore updates and inserts, the dirty fields of each state should be flushed. Datastore version information should be updated during flush, and the state manager's version indicator updated through the StateManagerImpl.setNextVersion(java.lang.Object) method. The current version will roll over to this next version upon successful commit.
Specified by:
flush in interface StoreManager

getDataStoreIdClass

public Class getDataStoreIdClass(ClassMetaData meta)
Description copied from interface: StoreManager
Return the class used by this StoreManager for datastore identity values.
Specified by:
getDataStoreIdClass in interface StoreManager

copyDataStoreId

public Object copyDataStoreId(Object oid,
                              ClassMetaData meta)
Description copied from interface: StoreManager
Copy the given object id value.
Specified by:
copyDataStoreId in interface StoreManager

newDataStoreId

public Object newDataStoreId(ClassMetaData meta)
Description copied from interface: StoreManager
Create a new unique datastore identity for the given type.
Specified by:
newDataStoreId in interface StoreManager

newDataStoreId

public Object newDataStoreId(String str,
                             ClassMetaData meta)
Description copied from interface: StoreManager
Create a new unique datastore identity for the given type from the given string.
Specified by:
newDataStoreId in interface StoreManager

newExtent

public Extent newExtent(ClassMetaData meta,
                        boolean subclasses)
Description copied from interface: StoreManager
Return an extent of the given candidate class, optionally including subclasses. If the extent is iterated within a data store transaction, returned instances should be locked.
Specified by:
newExtent in interface StoreManager

newQuery

public Query newQuery(String language,
                      Object copy)
Description copied from interface: StoreManager
Return a query implementation suitable for this runtime. If the query is iterated within a data store transaction, returned instances should be locked.
Specified by:
newQuery in interface StoreManager
Following copied from interface: com.solarmetric.kodo.runtime.StoreManager
Parameters:
the - query language; implementations are only required to support javax.jdo.query.JDOQL
a - template query instance also from this StoreManager; this instance may be null; if not null, the filter, variables, parameters, imports, and candidate class should be copied from the template to the returned Query instance

newFilterExtensions

public com.solarmetric.kodo.query.FilterExtensions newFilterExtensions()
Description copied from interface: StoreManager
Return a FilterExtensions implementation for use in queries. To return no extensions, do:
return FilterExtensions.DefaultExtensions.newExtensions ()
Specified by:
newFilterExtensions in interface StoreManager

isActive

public boolean isActive()
Returns true if there is a data store transaction active.

getConnection

public Connection getConnection()
                         throws SQLException
Returns a Connection to the data store. If a transaction is not currently in progress, then the Connection will not be associated with this store manager's transaction, otherwise it will be the same transaction that is currently being used by the transaction.

releaseConnection

public void releaseConnection(Connection c)
                       throws SQLException
Releases the obtained Connection. If a transaction is in progress, and the Connection argument is the same as the Connection that is currently in use, then no action will be taken. Otherwise, the Connection will be closed.

getSQLExecutionManager

public SQLExecutionManager getSQLExecutionManager()
Return a SQLExecutionManager for interaction with the database; if there is a transaction in progress the connection will be transactionally consistent.

getConnector

public Connector getConnector()
Returns a Connector, which can be used to obtain a Connection instance.

getDictionary

public DBDictionary getDictionary()
Obtain a DBDictionary that used this PersistenceManagerImpl's Connector.

release

public void release(SQLExecutionManager manager)
Release the SQLExecutionManager if appropriate (i.e., if we do not have an active datastore transaction).

SQLExceptions will be consummed and logged to the runtime log.


executeQuery

protected ResultList executeQuery(ClassMapping cm,
                                  SQLExecutionManager sqlem,
                                  PreparedStatement stmnt,
                                  boolean subs)
Execute the given prepared statement loading instances through the given mapping. The statement will not be closed.

executeQuery

protected ResultList executeQuery(ObjectSelect sel,
                                  Class type,
                                  boolean subs)
Load all matching objects for the given query.
Parameters:
subs - if true, matching subclasses will also be returned

createFromResultSet

public Object createFromResultSet(ClassMapping cm,
                                  SQLExecutionManager sqlem,
                                  ResultSet rs,
                                  FieldMetaData[] fmds,
                                  int index)
Create an instance from the given result set; if the instance is already cached it will be returned.
Parameters:
cm - the mapping for a base type of the instance
sqlem - A SQLExecutionManager that can be used for loading additional data.
rs - the result set to load from
fmds - an array of FieldMetaData objects to load
index - the column index to start at when loading

addSQLExecutionListener

public boolean addSQLExecutionListener(SQLExecutionListener listener)
Add a listener for all SQLExecution events.
Returns:
true if we successfully added the listener
Since:
2.4

removeSQLExecutionListener

public boolean removeSQLExecutionListener(SQLExecutionListener listener)
Remove a listener for all SQLExecution events.
Returns:
true if we successfully removed the listener
Since:
2.4

SolarMetric Kodo JDO 2.4.3 generated on March 27 2003

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.