Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.3.5 generated on August 31 2005
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## kodo.jdbc.runtime
Class JDBCStoreManager

    java.lang.Object
      |
      +--kodo.jdbc.runtime.JDBCStoreManager

All Implemented Interfaces:
  com.solarmetric.util.Closeable, StoreManager

public class JDBCStoreManager
extends Object
implements StoreManager

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

Fields inherited from interface kodo.runtime.StoreManager
`FORCE_LOAD_ALL, FORCE_LOAD_DFG, FORCE_LOAD_NONE, FORCE_LOAD_REFRESH, VERSION_DIFFERENT, VERSION_EARLIER, VERSION_LATER, VERSION_SAME`

Constructor Summary
`JDBCStoreManager()`

Method Summary
`boolean` | `addClassConditions(Select sel, ClassMapping mapping, boolean subs, Joins joins)` Add WHERE conditions to the given select limiting the returned results to the given mapping type, possibly including subclasses.
`boolean` | `assignObjectId(KodoStateManager sm)` Assign an object id to the given new instance.
`void` | `begin()` Begin a data store transaction.
`void` | `beginOptimistic()` Notification that an optimistic transaction has started.
`boolean` | `cancelAll()` Cancel all pending data store statements.
`void` | `changeJDOState(KodoStateManager sm, JDOState fromState, JDOState toState)` Notification that the given state manager is about to change its JDO state.
`void` | `close()` Free any resources this store manager is using.
`void` | `commit()` Commit the current data store transaction.
`int` | `compareVersion(KodoStateManager state, Object v1, Object v2)` Compare the two version objects.
`Object` | `copyDataStoreId(Object oid, ClassMetaData meta)` Copy the given object id value.
`boolean` | `exists(KodoStateManager sm, Object context)` Verify that the given instance exists in the data store; return false if it does not.
`Collection` | `flush(Collection states)` Flush the given state manager collection to the datastore, returning a collection of exceptions encountered during flushing.
`JDBCConfiguration` | `getConfiguration()` Return the configuration for this runtime.
`Object` | `getConnection()` Return a connection to the data store.
`int` | `getCount(Select sel)` Return the count for the given query.
`Class` | `getDataStoreIdClass(ClassMetaData meta)` Return the class used by this StoreManager for datastore identity values.
`Connection` | `getJDBCConnection()` Return a SQL connection to the database.
`JDBCLockManager` | `getJDBCLockManager()` Return the jdbc lock manager, or null if the lock manager does not implement `JDBCLockManager`.
`Class` | `getPersistenceCapableClass(Object oid)` Return the persistent class for the given data store identity value.
`KodoPersistenceManager` | `getPersistenceManager()` Return the PersistenceManager this StoreManager is owned by.
`SequenceGenerator` | `getSequenceGenerator(ClassMetaData meta)` Returns a `SequenceGenerator` for the specified class.
`boolean` | `hasConnection()` Return true if this store manager has established a dedicated connection to the data store.
`boolean` | `initialize(KodoStateManager sm, JDOState state, FetchConfiguration fetch, Object context)` Initialize the given state manager.
`boolean` | `isActive()` Return whether there is a datastore transaction active.
`boolean` | `load(KodoStateManager sm, BitSet fields, FetchConfiguration fetch, int lockLevel, Object context)` Load the given state manager.
`Object` | `load(Object oid, JDBCFetchConfiguration fetch)` Load the object with the given oid.
`Collection` | `loadAll(Collection sms, JDOState state, int load, FetchConfiguration fetch, Object context)` Initialize, load, or validate the existance of all of the given objects.
`Object` | `loadMappings(ClassMapping mapping, JDBCFetchConfiguration fetch, BitSet exclude, Result result)` For implementation use only.
`void` | `loadSubclasses(ClassMapping mapping)` Makes sure all subclasses of the given type are loaded in the JVM.
`Id` | `newDataStoreId(long id, ClassMapping mapping)` Create a new datastore identity object from the given id value and mapping.
`Object` | `newDataStoreId(Object oidVal, ClassMetaData meta)` Create a new unique datastore identity for the given type from the given oid value (presumably pk, stringified oid, or oid instance).
`KodoExtent` | `newExtent(Class cls, boolean subclasses)` Return an extent of the given candidate class, optionally including subclasses.
`FetchConfiguration` | `newFetchConfiguration()` Return a fetch configuration suitable for this runtime.
`KodoQuery` | `newQuery(String language)` Return a query implementation suitable for this runtime.
`void` | `rollback()` Rollback the current data store transaction.
`void` | `rollbackOptimistic()` Notification that an optimistic transaction was rolled back before a data store transaction ever began.
`boolean` | `selectMappings(Select sel, ClassMapping mapping, int subs, KodoStateManager sm, BitSet fields, JDBCFetchConfiguration fetch, int eager, boolean ident)` For implementation use only.
`void` | `setPersistenceManager(KodoPersistenceManager pm)` Set the PersistenceManager this StoreManager is owned by.
`boolean` | `synchVersion(KodoStateManager sm, Object context)` 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 KodoPersistenceManager getPersistenceManager()

  Return the PersistenceManager this StoreManager is owned by.

### setPersistenceManager

    public void setPersistenceManager(KodoPersistenceManager pm)

  Set the PersistenceManager this StoreManager is owned by.
  Specified by:
    `setPersistenceManager` in interface `StoreManager`

### getConfiguration

    public 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`

### rollbackOptimistic

    public void rollbackOptimistic()

  Description copied from interface: `StoreManager`
  Notification that an optimistic transaction was rolled back before a data store transaction ever began.
  Specified by:
    `rollbackOptimistic` in interface `StoreManager`

### begin

    public void begin()

  Description copied from interface: `StoreManager`
  Begin a data store transaction. After this method is called, it is assumed that all further operations are operating in a single transaction that can be committed or rolled back. If optimistic transactions are in use, this method will only be called when the system requires a transactionally consistent connection due to a user request to flush or commit the JDO 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`

### getConnection

    public Object getConnection()

  Description copied from interface: `StoreManager`
  Return a connection to the data store. If this method is called during a data store transaction, thie connection must be transactional. If no connection is in use, this method should create one to return.
  Specified by:
    `getConnection` in interface `StoreManager`

### hasConnection

    public boolean hasConnection()

  Description copied from interface: `StoreManager`
  Return true if this store manager has established a dedicated connection to the data store. This typically depends on the transactional state and `KodoPersistenceManager.getConnectionRetainMode()`.
  Specified by:
    `hasConnection` in interface `StoreManager`

### exists

    public boolean exists(KodoStateManager sm,
                          Object context)

  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(KodoStateManager sm,
                                Object context)

  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`
  Following copied from interface: `kodo.runtime.StoreManager`
  Parameters:
    `sm` - the instance to check
    `context` - the current context information, or null if not given to the calling method of the persistence manager
  Returns:
    true if the instance still exists in the datastore and is up-to-date, false otherwise

### compareVersion

    public int compareVersion(KodoStateManager state,
                              Object v1,
                              Object v2)

  Description copied from interface: `StoreManager`
  Compare the two version objects.
  Specified by:
    `compareVersion` in interface `StoreManager`
  Following copied from interface: `kodo.runtime.StoreManager`
  Parameters:
    `state` - the state manager for the object
    `v1` - the first version object to compare
    `v2` - the second version object to compare
  Returns:
    - `StoreManager.VERSION_LATER` if `v1` is later than `v2`
    - `StoreManager.VERSION_EARLIER` if `v1` is earlier than `v2`
    - `StoreManager.VERSION_SAME` if `v1` is the same as `v2`
    - `StoreManager.VERSION_DIFFERENT` if `v1` is different from `v2`, but the time difference of the versions cannot be determined

### initialize

    public boolean initialize(KodoStateManager sm,
                              JDOState state,
                              FetchConfiguration fetch,
                              Object context)

  Description copied from interface: `StoreManager`
  Initialize the given state manager. The object id of the state manager will be set, and the state manager's metadata be set to the class of the instance to load, or possibly one of its superclasses. Initialization involves first calling the `KodoStateManager.initialize(javax.jdo.spi.PersistenceCapable, 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 state manager's metadata if the actual type was a subclass). After instance initialization, load any the fields for the given fetch configuration that can be efficiently retrieved. If any of the configured fields are not loaded in this method, they will be loaded with a subsequent call to `StoreManager.load(kodo.runtime.KodoStateManager, java.util.BitSet, kodo.runtime.FetchConfiguration, int, java.lang.Object)`. 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 `KodoStateManager.setVersion(java.lang.Object)` method.
  Specified by:
    `initialize` in interface `StoreManager`
  Following copied from interface: `kodo.runtime.StoreManager`
  Parameters:
    `sm` - the instance to initialize
    `state` - the lifecycle state to initialize the state manager with
    `fetch` - configuration for how to load the instance
    `context` - the current context 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 boolean load(KodoStateManager sm,
                        BitSet fields,
                        FetchConfiguration fetch,
                        int lockLevel,
                        Object context)

  Description copied from interface: `StoreManager`
  Load the given state manager. Note that any collection or map types loaded into the state manager will be proxied with the correct type; therefore the stroe manager 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 persistence capable 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 `KodoStateManager.setVersion(java.lang.Object)` method.
  Specified by:
    `load` in interface `StoreManager`
  Following copied from interface: `kodo.runtime.StoreManager`
  Parameters:
    `sm` - the instance to load
    `fields` - set of fields to load; all field indexes in this set must be loaded; this set is mutable
    `fetch` - the fetch configuration to use when loading related objects
    `lockLevel` - attempt to load simple fields at this lock level; relations should be loaded at the read lock level of the fetch configuration
    `context` - the current context information, or null if not given to the calling method of the persistence manager
  Returns:
    false if the object no longer exists in the database, true otherwise

### loadAll

    public Collection loadAll(Collection sms,
                              JDOState state,
                              int load,
                              FetchConfiguration fetch,
                              Object context)

  Description copied from interface: `StoreManager`
  Initialize, load, or validate the existance of all of the given objects. This method is called from various persistence manager methods that act on multiple objects, such as `KodoPersistenceManager.getObjectsById(java.lang.Object[], boolean)`. It gives the store manager an opportunity to efficiently batch-load data for several objects. Each of the given state managers will be in one of three states, each requiring a different action:
  - `stateManager.getPersistenceCapable () == null`: An uninitialized state manager. Perform the same actions as in `StoreManager.initialize(kodo.runtime.KodoStateManager, kodo.runtime.JDOState, kodo.runtime.FetchConfiguration, java.lang.Object)`.
  - `load != FORCE_LOAD_NONE || stateManager.getJDOState () == JDOState.HOLLOW`: A hollow state manager, or one whose fields must be loaded because this is a refresh or retrieve action. Peform the same actions as in `StoreManager.load(kodo.runtime.KodoStateManager, java.util.BitSet, kodo.runtime.FetchConfiguration, int, java.lang.Object)`, choosing the fields to load based on the fetch configuration, or loading all fields if `load == FORCE_LOAD_ALL`. Any required fields left unloaded will cause a subsequent invocation of `StoreManager.load(kodo.runtime.KodoStateManager, java.util.BitSet, kodo.runtime.FetchConfiguration, int, java.lang.Object)` on the individual object in question.
  - `load == FORCE_LOAD_NONE && stateManager.getJDOState () != JDOState.HOLLOW`: A non-hollow state manager. Perform the same actions as in `StoreManager.exists(kodo.runtime.KodoStateManager, java.lang.Object)`, and load additional state if desired. Non-hollow objects will only be included outside of refresh invocations if a user calls `getObjectsById` with the `validate` parameter set to `true`.
  Store managers that cannot efficiently batch load can simply test for these conditions and delegate to the proper methods.
  Specified by:
    `loadAll` in interface `StoreManager`
  Following copied from interface: `kodo.runtime.StoreManager`
  Parameters:
    `sms` - the state manager instances to load
    `state` - the lifecycle state to initialize uninitialized state managers with; may be null if no uninitialized instances are included in `sms`
    `load` - one of the FORCE_LOAD_* constants describing the fields to force-load if this is a refresh or retrieve action
    `fetch` - the current fetch configuration to use when loading related objects
    `context` - the current context information, or null if not given to the calling method of the persistence manager
  Returns:
    a collection of the state manager identities for which no data store record exists

### changeJDOState

    public void changeJDOState(KodoStateManager sm,
                               JDOState fromState,
                               JDOState toState)

  Description copied from interface: `StoreManager`
  Notification that the given state manager is about to change its JDO state. The store manager is not required to do anything in this method, but some back ends may need to.
  Specified by:
    `changeJDOState` in interface `StoreManager`

### flush

    public Collection flush(Collection states)

  Description copied from interface: `StoreManager`
  Flush the given state manager collection to the datastore, returning a collection of exceptions encountered during flushing. The given collection may include states that do not require data store action, such as persistent-clean instances or persistent-dirty instances that have not been modified since they were last flushed. For datastore updates and inserts, the dirty, non-flushed fields of each state should be flushed. New instances without an assigned object id should be given one via `KodoStateManager.setObjectId(java.lang.Object)`. Datastore version information should be updated during flush, and the state manager's version indicator updated through the `KodoStateManager.setNextVersion(java.lang.Object)` method. The current version will roll over to this next version upon successful commit.
  Specified by:
    `flush` in interface `StoreManager`

### cancelAll

    public boolean cancelAll()

  Description copied from interface: `StoreManager`
  Cancel all pending data store statements.
  Specified by:
    `cancelAll` in interface `StoreManager`
  Following copied from interface: `kodo.runtime.StoreManager`
  Returns:
    true if any statements cancelled, false otherwise

### getPersistenceCapableClass

    public Class getPersistenceCapableClass(Object oid)

  Description copied from interface: `StoreManager`
  Return the persistent class for the given data store identity value. If the given value is not a datastore identity object, return null.
  Specified by:
    `getPersistenceCapableClass` in interface `StoreManager`

### assignObjectId

    public boolean assignObjectId(KodoStateManager sm)

  Description copied from interface: `StoreManager`
  Assign an object id to the given new instance. Return false if the instance cannot be assigned an identity because a flush is required (for example, the identity is determined by the datastore on insert). For application identity instances, the assigned object id should be based on field state. This method is called the first time a user requests the oid of a new instance before flush.
  Specified by:
    `assignObjectId` in interface `StoreManager`
  Following copied from interface: `kodo.runtime.StoreManager`
  See Also:
    `kodo.util.ApplicationIds#create`

### getDataStoreIdClass

    public Class getDataStoreIdClass(ClassMetaData meta)

  Description copied from interface: `StoreManager`
  Return the class used by this StoreManager for datastore identity values. The given metadata may be null, in which case the return value should the common datastore identity class for all classes, or null if this store manager does not use a common identity class.
  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(Object oidVal,
                                 ClassMetaData meta)

  Description copied from interface: `StoreManager`
  Create a new unique datastore identity for the given type from the given oid value (presumably pk, stringified oid, or oid instance).
  Specified by:
    `newDataStoreId` in interface `StoreManager`

### newDataStoreId

    public Id newDataStoreId(long id,
                             ClassMapping mapping)

  Create a new datastore identity object from the given id value and mapping.

### newExtent

    public KodoExtent newExtent(Class cls,
                                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 KodoQuery newQuery(String language)

  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: `kodo.runtime.StoreManager`
  Parameters:
    `language` - the query language; implementations are only required to support `javax.jdo.query.JDOQL`

### newFetchConfiguration

    public FetchConfiguration newFetchConfiguration()

  Description copied from interface: `StoreManager`
  Return a fetch configuration suitable for this runtime. Typically will be or extend `FetchConfigurationImpl`.
  Specified by:
    `newFetchConfiguration` in interface `StoreManager`

### getSequenceGenerator

    public SequenceGenerator getSequenceGenerator(ClassMetaData meta)

  Description copied from interface: `StoreManager`
  Returns a `SequenceGenerator` for the specified class.
  Specified by:
    `getSequenceGenerator` in interface `StoreManager`

### close

    public void close()

  Description copied from interface: `StoreManager`
  Free any resources this store manager is using.
  Specified by:
    `close` in interface `StoreManager`

### isActive

    public boolean isActive()

  Return whether there is a datastore transaction active.

### getJDBCLockManager

    public JDBCLockManager getJDBCLockManager()

  Return the jdbc lock manager, or null if the lock manager does not implement `JDBCLockManager`.

### getJDBCConnection

    public Connection getJDBCConnection()

  Return a SQL connection to the database. This method is equivalent to `StoreManager.getConnection()`, but does not require you to cast the returned object to a SQL connection. The `close` method should always be called on the connection to free any resources it is using. When appropriate, the close method is implemented as a no-op.

### loadMappings

    public Object loadMappings(ClassMapping mapping,
                               JDBCFetchConfiguration fetch,
                               BitSet exclude,
                               Result result)
                        throws SQLException

  For implementation use only. Load the object in the current row of the given result.

### load

    public Object load(Object oid,
                       JDBCFetchConfiguration fetch)

  Load the object with the given oid.

### getCount

    public int getCount(Select sel)
                 throws SQLException

  Return the count for the given query.

### selectMappings

    public boolean selectMappings(Select sel,
                                  ClassMapping mapping,
                                  int subs,
                                  KodoStateManager sm,
                                  BitSet fields,
                                  JDBCFetchConfiguration fetch,
                                  int eager,
                                  boolean ident)

  For implementation use only. Return a select for the proper mappings. Return null if no select is needed. The method is designed to be complementary to the load methods.
  Parameters:
    `sel` - select to build on
    `mapping` - the mapping for the base type to select for
    `subs` - whether the select might include subclasses of the given mapping
    `sm` - state manager if an instance is being loaded or initialized, else null
    `fields` - if a state manager is being loaded, the set of fields that must be loaded in JDO order, else null
    `fetch` - the fetch configuration; used if no specific fields must be loaded, and used when selecting relations
    `eager` - eager fetch mode to use
    `ident` - whether to select primary key columns as distinct identifiers
  Returns:
    true if the select is required, false otherwise

### loadSubclasses

    public void loadSubclasses(ClassMapping mapping)

  Makes sure all subclasses of the given type are loaded in the JVM. This is usually done automatically.

### addClassConditions

    public boolean addClassConditions(Select sel,
                                      ClassMapping mapping,
                                      boolean subs,
                                      Joins joins)

  Add WHERE conditions to the given select limiting the returned results to the given mapping type, possibly including subclasses.
  Returns:
    true if the mapping was joined down to its base class in order to add the conditions

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.3.5 generated on August 31 2005
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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