org.apache.openjpa.jdbc.kernel
Class JDBCStoreManager

java.lang.Object
  extended by org.apache.openjpa.jdbc.kernel.JDBCStoreManager
All Implemented Interfaces:
JDBCStore, org.apache.openjpa.kernel.StoreManager, org.apache.openjpa.lib.util.Closeable

public class JDBCStoreManager
extends java.lang.Object
implements org.apache.openjpa.kernel.StoreManager, JDBCStore

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

Author:
Abe White

Field Summary
 
Fields inherited from interface org.apache.openjpa.kernel.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 assignField(org.apache.openjpa.kernel.OpenJPAStateManager sm, int field, boolean preFlush)
           
 boolean assignObjectId(org.apache.openjpa.kernel.OpenJPAStateManager sm, boolean preFlush)
           
 void beforeStateChange(org.apache.openjpa.kernel.OpenJPAStateManager sm, org.apache.openjpa.kernel.PCState fromState, org.apache.openjpa.kernel.PCState toState)
           
 void begin()
           
 void beginOptimistic()
           
 boolean cancelAll()
           
 void close()
           
 void commit()
           
 int compareVersion(org.apache.openjpa.kernel.OpenJPAStateManager state, java.lang.Object v1, java.lang.Object v2)
           
 java.lang.Object copyDataStoreId(java.lang.Object oid, org.apache.openjpa.meta.ClassMetaData meta)
           
 org.apache.openjpa.lib.rop.ResultObjectProvider executeExtent(org.apache.openjpa.meta.ClassMetaData meta, boolean subclasses, org.apache.openjpa.kernel.FetchConfiguration fetch)
           
 boolean exists(org.apache.openjpa.kernel.OpenJPAStateManager sm, java.lang.Object context)
           
 java.lang.Object find(java.lang.Object oid, ValueMapping vm, JDBCFetchConfiguration fetch)
          Find the object with the given oid.
 java.util.Collection flush(java.util.Collection sms)
           
 java.lang.Object getClientConnection()
           
 JDBCConfiguration getConfiguration()
          Return the configuration for this runtime.
 java.sql.Connection getConnection()
          Return a SQL connection to the database.
 org.apache.openjpa.kernel.StoreContext getContext()
          Current persistence context.
 org.apache.openjpa.kernel.Seq getDataStoreIdSequence(org.apache.openjpa.meta.ClassMetaData meta)
           
 java.lang.Class getDataStoreIdType(org.apache.openjpa.meta.ClassMetaData meta)
           
 DBDictionary getDBDictionary()
          Return the dictionary in use.
 JDBCFetchConfiguration getFetchConfiguration()
          Return the current default fetch configuration.
 JDBCLockManager getLockManager()
          If the lock manager in use is a JDBCLockManager, return it.
 java.lang.Class getManagedType(java.lang.Object oid)
           
 SQLFactory getSQLFactory()
          Return the SQL factory for this runtime.
 org.apache.openjpa.kernel.Seq getValueSequence(org.apache.openjpa.meta.FieldMetaData fmd)
           
 boolean initialize(org.apache.openjpa.kernel.OpenJPAStateManager sm, org.apache.openjpa.kernel.PCState state, org.apache.openjpa.kernel.FetchConfiguration fetch, java.lang.Object context)
           
 java.lang.Object load(ClassMapping mapping, JDBCFetchConfiguration fetch, java.util.BitSet exclude, Result result)
          Load the object in the current row of the given result.
 boolean load(org.apache.openjpa.kernel.OpenJPAStateManager sm, java.util.BitSet fields, org.apache.openjpa.kernel.FetchConfiguration fetch, int lockLevel, java.lang.Object context)
           
 java.util.Collection loadAll(java.util.Collection sms, org.apache.openjpa.kernel.PCState state, int load, org.apache.openjpa.kernel.FetchConfiguration fetch, java.lang.Object context)
           
 void loadSubclasses(ClassMapping mapping)
          Makes sure all subclasses of the given type are loaded in the JVM.
 org.apache.openjpa.util.Id newDataStoreId(long id, ClassMapping mapping, boolean subs)
          Create a new datastore identity object from the given id value and mapping.
 java.lang.Object newDataStoreId(java.lang.Object val, org.apache.openjpa.meta.ClassMetaData meta)
           
 org.apache.openjpa.kernel.FetchConfiguration newFetchConfiguration()
           
 org.apache.openjpa.kernel.StoreQuery newQuery(java.lang.String language)
           
 void releaseConnection()
           
 void retainConnection()
           
 void rollback()
           
 void rollbackOptimistic()
           
 boolean select(Select sel, ClassMapping mapping, int subs, org.apache.openjpa.kernel.OpenJPAStateManager sm, java.util.BitSet fields, JDBCFetchConfiguration fetch, int eager, boolean ident)
          For implementation use only.
 void setContext(org.apache.openjpa.kernel.StoreContext ctx)
           
 boolean syncVersion(org.apache.openjpa.kernel.OpenJPAStateManager sm, java.lang.Object context)
           
 
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

getContext

public org.apache.openjpa.kernel.StoreContext getContext()
Description copied from interface: JDBCStore
Current persistence context.

Specified by:
getContext in interface JDBCStore

setContext

public void setContext(org.apache.openjpa.kernel.StoreContext ctx)
Specified by:
setContext in interface org.apache.openjpa.kernel.StoreManager

getConfiguration

public JDBCConfiguration getConfiguration()
Description copied from interface: JDBCStore
Return the configuration for this runtime.

Specified by:
getConfiguration in interface JDBCStore

getDBDictionary

public DBDictionary getDBDictionary()
Description copied from interface: JDBCStore
Return the dictionary in use.

Specified by:
getDBDictionary in interface JDBCStore

getSQLFactory

public SQLFactory getSQLFactory()
Description copied from interface: JDBCStore
Return the SQL factory for this runtime.

Specified by:
getSQLFactory in interface JDBCStore

getLockManager

public JDBCLockManager getLockManager()
Description copied from interface: JDBCStore
If the lock manager in use is a JDBCLockManager, return it.

Specified by:
getLockManager in interface JDBCStore

getFetchConfiguration

public JDBCFetchConfiguration getFetchConfiguration()
Description copied from interface: JDBCStore
Return the current default fetch configuration.

Specified by:
getFetchConfiguration in interface JDBCStore

beginOptimistic

public void beginOptimistic()
Specified by:
beginOptimistic in interface org.apache.openjpa.kernel.StoreManager

rollbackOptimistic

public void rollbackOptimistic()
Specified by:
rollbackOptimistic in interface org.apache.openjpa.kernel.StoreManager

begin

public void begin()
Specified by:
begin in interface org.apache.openjpa.kernel.StoreManager

commit

public void commit()
Specified by:
commit in interface org.apache.openjpa.kernel.StoreManager

rollback

public void rollback()
Specified by:
rollback in interface org.apache.openjpa.kernel.StoreManager

retainConnection

public void retainConnection()
Specified by:
retainConnection in interface org.apache.openjpa.kernel.StoreManager

releaseConnection

public void releaseConnection()
Specified by:
releaseConnection in interface org.apache.openjpa.kernel.StoreManager

getClientConnection

public java.lang.Object getClientConnection()
Specified by:
getClientConnection in interface org.apache.openjpa.kernel.StoreManager

getConnection

public java.sql.Connection getConnection()
Description copied from interface: JDBCStore
Return a SQL connection to the database. 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.

Specified by:
getConnection in interface JDBCStore

exists

public boolean exists(org.apache.openjpa.kernel.OpenJPAStateManager sm,
                      java.lang.Object context)
Specified by:
exists in interface org.apache.openjpa.kernel.StoreManager

syncVersion

public boolean syncVersion(org.apache.openjpa.kernel.OpenJPAStateManager sm,
                           java.lang.Object context)
Specified by:
syncVersion in interface org.apache.openjpa.kernel.StoreManager

compareVersion

public int compareVersion(org.apache.openjpa.kernel.OpenJPAStateManager state,
                          java.lang.Object v1,
                          java.lang.Object v2)
Specified by:
compareVersion in interface org.apache.openjpa.kernel.StoreManager

initialize

public boolean initialize(org.apache.openjpa.kernel.OpenJPAStateManager sm,
                          org.apache.openjpa.kernel.PCState state,
                          org.apache.openjpa.kernel.FetchConfiguration fetch,
                          java.lang.Object context)
Specified by:
initialize in interface org.apache.openjpa.kernel.StoreManager

load

public boolean load(org.apache.openjpa.kernel.OpenJPAStateManager sm,
                    java.util.BitSet fields,
                    org.apache.openjpa.kernel.FetchConfiguration fetch,
                    int lockLevel,
                    java.lang.Object context)
Specified by:
load in interface org.apache.openjpa.kernel.StoreManager

loadAll

public java.util.Collection loadAll(java.util.Collection sms,
                                    org.apache.openjpa.kernel.PCState state,
                                    int load,
                                    org.apache.openjpa.kernel.FetchConfiguration fetch,
                                    java.lang.Object context)
Specified by:
loadAll in interface org.apache.openjpa.kernel.StoreManager

beforeStateChange

public void beforeStateChange(org.apache.openjpa.kernel.OpenJPAStateManager sm,
                              org.apache.openjpa.kernel.PCState fromState,
                              org.apache.openjpa.kernel.PCState toState)
Specified by:
beforeStateChange in interface org.apache.openjpa.kernel.StoreManager

flush

public java.util.Collection flush(java.util.Collection sms)
Specified by:
flush in interface org.apache.openjpa.kernel.StoreManager

cancelAll

public boolean cancelAll()
Specified by:
cancelAll in interface org.apache.openjpa.kernel.StoreManager

assignObjectId

public boolean assignObjectId(org.apache.openjpa.kernel.OpenJPAStateManager sm,
                              boolean preFlush)
Specified by:
assignObjectId in interface org.apache.openjpa.kernel.StoreManager

assignField

public boolean assignField(org.apache.openjpa.kernel.OpenJPAStateManager sm,
                           int field,
                           boolean preFlush)
Specified by:
assignField in interface org.apache.openjpa.kernel.StoreManager

getManagedType

public java.lang.Class getManagedType(java.lang.Object oid)
Specified by:
getManagedType in interface org.apache.openjpa.kernel.StoreManager

getDataStoreIdType

public java.lang.Class getDataStoreIdType(org.apache.openjpa.meta.ClassMetaData meta)
Specified by:
getDataStoreIdType in interface org.apache.openjpa.kernel.StoreManager

copyDataStoreId

public java.lang.Object copyDataStoreId(java.lang.Object oid,
                                        org.apache.openjpa.meta.ClassMetaData meta)
Specified by:
copyDataStoreId in interface org.apache.openjpa.kernel.StoreManager

newDataStoreId

public java.lang.Object newDataStoreId(java.lang.Object val,
                                       org.apache.openjpa.meta.ClassMetaData meta)
Specified by:
newDataStoreId in interface org.apache.openjpa.kernel.StoreManager

newDataStoreId

public org.apache.openjpa.util.Id newDataStoreId(long id,
                                                 ClassMapping mapping,
                                                 boolean subs)
Description copied from interface: JDBCStore
Create a new datastore identity object from the given id value and mapping.

Specified by:
newDataStoreId in interface JDBCStore

executeExtent

public org.apache.openjpa.lib.rop.ResultObjectProvider executeExtent(org.apache.openjpa.meta.ClassMetaData meta,
                                                                     boolean subclasses,
                                                                     org.apache.openjpa.kernel.FetchConfiguration fetch)
Specified by:
executeExtent in interface org.apache.openjpa.kernel.StoreManager

newQuery

public org.apache.openjpa.kernel.StoreQuery newQuery(java.lang.String language)
Specified by:
newQuery in interface org.apache.openjpa.kernel.StoreManager

newFetchConfiguration

public org.apache.openjpa.kernel.FetchConfiguration newFetchConfiguration()
Specified by:
newFetchConfiguration in interface org.apache.openjpa.kernel.StoreManager

getDataStoreIdSequence

public org.apache.openjpa.kernel.Seq getDataStoreIdSequence(org.apache.openjpa.meta.ClassMetaData meta)
Specified by:
getDataStoreIdSequence in interface org.apache.openjpa.kernel.StoreManager

getValueSequence

public org.apache.openjpa.kernel.Seq getValueSequence(org.apache.openjpa.meta.FieldMetaData fmd)
Specified by:
getValueSequence in interface org.apache.openjpa.kernel.StoreManager

close

public void close()
Specified by:
close in interface org.apache.openjpa.kernel.StoreManager
Specified by:
close in interface org.apache.openjpa.lib.util.Closeable

find

public java.lang.Object find(java.lang.Object oid,
                             ValueMapping vm,
                             JDBCFetchConfiguration fetch)
Find the object with the given oid.

Specified by:
find in interface JDBCStore
vm - the mapping holding this oid, or null if not applicable

load

public java.lang.Object load(ClassMapping mapping,
                             JDBCFetchConfiguration fetch,
                             java.util.BitSet exclude,
                             Result result)
                      throws java.sql.SQLException
Load the object in the current row of the given result.

Throws:
java.sql.SQLException

select

public boolean select(Select sel,
                      ClassMapping mapping,
                      int subs,
                      org.apache.openjpa.kernel.OpenJPAStateManager sm,
                      java.util.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 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.

Specified by:
loadSubclasses in interface JDBCStore

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.

Specified by:
addClassConditions in interface JDBCStore
Returns:
true if the mapping was joined down to its base class in order to add the conditions


Copyright © 2006 Apache Software Foundation. All Rights Reserved.