SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

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

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

public class JDBCStoreManager
extends java.lang.Object
implements StoreManager

StoreManager plugin that uses JDBC to store persistent data in a relational data store.


Constructor Summary
JDBCStoreManager()
           
 
Method Summary
 void begin()
          Begin a data store transaction.
 void beginOptimistic()
          Notification that an optimistic transaction has started.
 void commit()
          Commit the current data store transaction.
 java.lang.Object copyDataStoreId(java.lang.Object oid, com.solarmetric.rd.kodo.meta.ClassMetaData meta)
          Copy the given object id value.
 boolean exists(java.lang.Object oid, com.solarmetric.rd.kodo.meta.ClassMetaData meta)
          Verify that the given instance exists in the data store; return false if it does not.
 java.util.Collection flush(java.util.Collection states)
          Flush the given state manager collection to the datastore, returning a collection of user exceptions encountered during flushing.
 com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration getConfiguration()
          Return the configuration for this runtime.
 java.sql.Connection getConnection()
          Return a connection to the data store.
 java.lang.Class getDataStoreIdClass(com.solarmetric.rd.kodo.meta.ClassMetaData meta)
          Return the class used by this StoreManager for datastore identity values.
 com.solarmetric.rd.kodo.runtime.PersistenceManagerImpl getPersistenceManager()
          Return the PersistenceManager this StoreManager is owned by.
 com.solarmetric.rd.kodo.impl.jdbc.runtime.Result getResult(com.solarmetric.rd.kodo.impl.jdbc.runtime.Select sel, java.sql.Connection conn)
          Return the result of executing the given query.
 boolean initialize(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm, com.solarmetric.rd.kodo.runtime.JDOState state, java.lang.Object connection)
          Initialize the given StateManager.
 boolean isActive()
          Return true if there is a data store transaction active.
 com.solarmetric.rd.rop.ResultList load(com.solarmetric.rd.kodo.impl.jdbc.meta.ClassMapping mapping, boolean subclasses, java.sql.Connection conn, int fetchThreshold, int fetchBatchSize)
          Return a result containing records for all instances of the given type.
 com.solarmetric.rd.rop.ResultList load(com.solarmetric.rd.kodo.impl.jdbc.meta.ClassMapping mapping, boolean subclasses, java.lang.String queryName, java.util.Map params, java.sql.Connection conn, int fetchThreshold, int fetchBatchSize)
          Return the result of executing the given named query.
 java.lang.Object load(com.solarmetric.rd.kodo.impl.jdbc.meta.ClassMapping mapping, java.lang.Object oid, com.solarmetric.rd.kodo.impl.jdbc.runtime.Result result)
          Load the object in the current row of the given result, optionally supplying the oid of the object if it has already been read.
 java.lang.Object load(java.lang.Object oid, java.sql.Connection conn)
          Load the object with the given oid.
 void load(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm, int field, java.lang.Object connection)
          Load the given StateManager.
 java.lang.Object newDataStoreId(com.solarmetric.rd.kodo.meta.ClassMetaData meta)
          Create a new unique datastore identity for the given type.
 java.lang.Object newDataStoreId(java.lang.String str, com.solarmetric.rd.kodo.meta.ClassMetaData meta)
          Create a new unique datastore identity for the given type from the given string.
 javax.jdo.Extent newExtent(com.solarmetric.rd.kodo.meta.ClassMetaData meta, boolean subclasses)
          Return an extent of the given candidate class, optionally including subclasses.
 javax.jdo.Query newQuery(java.lang.String language, java.lang.Object copy)
          Return a query implementation suitable for this runtime.
 com.solarmetric.rd.kodo.impl.jdbc.runtime.Select newSelect()
          Return a new select for queries.
 void rollback()
          Rollback the current data store transaction.
 void setPersistenceManager(com.solarmetric.rd.kodo.runtime.PersistenceManagerImpl pm)
          Set the PersistenceManager this StoreManager is owned by.
 boolean synchVersion(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm, java.lang.Object connection)
          Update the version information in the given state manager to the version stored in the data store.
 
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 com.solarmetric.rd.kodo.runtime.PersistenceManagerImpl getPersistenceManager()
Return the PersistenceManager this StoreManager is owned by.


setPersistenceManager

public void setPersistenceManager(com.solarmetric.rd.kodo.runtime.PersistenceManagerImpl pm)
Set the PersistenceManager this StoreManager is owned by.

Specified by:
setPersistenceManager in interface StoreManager

getConfiguration

public com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration getConfiguration()
Return the configuration for this runtime.


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(java.lang.Object oid,
                      com.solarmetric.rd.kodo.meta.ClassMetaData meta)
Description copied from interface: StoreManager
Verify that the given instance exists in the data store; return false if it does not.

Specified by:
exists in interface StoreManager

synchVersion

public boolean synchVersion(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm,
                            java.lang.Object connection)
Description copied from interface: StoreManager
Update the version information in the given state manager to the version stored in the data store.

Specified by:
synchVersion in interface StoreManager
Parameters:
sm - the instance to check
connection - the current connection information, or null if not given to the calling method of the persistence manager
Returns:
true if the instance is up-to-date, false otherwise

initialize

public boolean initialize(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm,
                          com.solarmetric.rd.kodo.runtime.JDOState state,
                          java.lang.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.initialize(javax.jdo.spi.PersistenceCapable, com.solarmetric.rd.kodo.runtime.JDOState) 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 fields if if desired. If this method is called during a data store transaction, the instance's database record should be locked. Version information can be loaded if desired through the StateManagerImpl.setVersion(java.lang.Object) method.

Specified by:
initialize in interface StoreManager
Parameters:
sm - the instance to initialize
state - the lifecycle state to initialize the state manager with
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(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm,
                 int field,
                 java.lang.Object connection)
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. If the given state manager does not have its version set already, version information can be loaded if desired through the StateManagerImpl.setVersion(java.lang.Object) method.

Specified by:
load in interface StoreManager
Parameters:
sm - the instance to load
field - the field to load; the field corrsponding to the metadata field at the given absolute index 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
connection - the current connection information, or null if not given to the calling method of the persistence manager

flush

public java.util.Collection flush(java.util.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 java.lang.Class getDataStoreIdClass(com.solarmetric.rd.kodo.meta.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 java.lang.Object copyDataStoreId(java.lang.Object oid,
                                        com.solarmetric.rd.kodo.meta.ClassMetaData meta)
Description copied from interface: StoreManager
Copy the given object id value.

Specified by:
copyDataStoreId in interface StoreManager

newDataStoreId

public java.lang.Object newDataStoreId(com.solarmetric.rd.kodo.meta.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 java.lang.Object newDataStoreId(java.lang.String str,
                                       com.solarmetric.rd.kodo.meta.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 javax.jdo.Extent newExtent(com.solarmetric.rd.kodo.meta.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 javax.jdo.Query newQuery(java.lang.String language,
                                java.lang.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
Parameters:
language - the query language; implementations are only required to support javax.jdo.query.JDOQL
copy - 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

isActive

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


getConnection

public java.sql.Connection getConnection()
Return a connection to the data store. If this method is called during a data store transaction, the connection will transactional. The close method should always be called on the connection to free any resources it is using. During a transaction, the close method is implemented as a no-op. At other times, it usually returns the connection to the pool.


load

public com.solarmetric.rd.rop.ResultList load(com.solarmetric.rd.kodo.impl.jdbc.meta.ClassMapping mapping,
                                              boolean subclasses,
                                              java.sql.Connection conn,
                                              int fetchThreshold,
                                              int fetchBatchSize)
                                       throws java.sql.SQLException
Return a result containing records for all instances of the given type.

java.sql.SQLException

load

public com.solarmetric.rd.rop.ResultList load(com.solarmetric.rd.kodo.impl.jdbc.meta.ClassMapping mapping,
                                              boolean subclasses,
                                              java.lang.String queryName,
                                              java.util.Map params,
                                              java.sql.Connection conn,
                                              int fetchThreshold,
                                              int fetchBatchSize)
                                       throws java.sql.SQLException
Return the result of executing the given named query.

java.sql.SQLException

load

public java.lang.Object load(com.solarmetric.rd.kodo.impl.jdbc.meta.ClassMapping mapping,
                             java.lang.Object oid,
                             com.solarmetric.rd.kodo.impl.jdbc.runtime.Result result)
                      throws java.sql.SQLException
Load the object in the current row of the given result, optionally supplying the oid of the object if it has already been read.

java.sql.SQLException

load

public java.lang.Object load(java.lang.Object oid,
                             java.sql.Connection conn)
Load the object with the given oid.


getResult

public com.solarmetric.rd.kodo.impl.jdbc.runtime.Result getResult(com.solarmetric.rd.kodo.impl.jdbc.runtime.Select sel,
                                                                  java.sql.Connection conn)
                                                           throws java.sql.SQLException
Return the result of executing the given query.

java.sql.SQLException

newSelect

public com.solarmetric.rd.kodo.impl.jdbc.runtime.Select newSelect()
Return a new select for queries.


SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

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