org.exolab.castor.jdo.engine
Class SQLEngine

java.lang.Object
  extended by org.exolab.castor.jdo.engine.SQLEngine
All Implemented Interfaces:
Persistence

public final class SQLEngine
extends java.lang.Object
implements Persistence

The SQL engine performs persistence of one object type against one SQL database. It can only persist simple objects and extended relationships. An SQL engine is created for each object type represented by a database. When persisting, it requires a physical connection that maps to the SQL database and the transaction running on that database

Version:
$Revision: 1.38 $ $Date: 2005/10/13 07:40:54 $
Author:
Assaf Arkin, Thomas Yip, Bruce Snyder

Nested Class Summary
(package private) static class SQLEngine.ColumnInfo
           
(package private) static class SQLEngine.FieldInfo
           
(package private) static class SQLEngine.SQLQuery
           
 
Constructor Summary
SQLEngine(JDOClassDescriptor clsDesc, PersistenceFactory factory, java.lang.String stampField)
           
 
Method Summary
 java.lang.Object create(Database database, java.lang.Object conn, java.lang.Object[] fields, java.lang.Object identity)
          Creates a new object in persistence storage.
 PersistenceQuery createCall(java.lang.String spCall, java.lang.Class[] types)
           
 PersistenceQuery createQuery(QueryExpression query, java.lang.Class[] types, AccessMode accessMode)
          Creates and returns a new query object.
 void delete(java.lang.Object conn, java.lang.Object identity)
          Deletes the object from persistent storage, given the object' identity.
 Persistence.ColumnInfo[] getColumnInfoForIdentities()
          Returns ColumnInfos for identifiers.
 JDOClassDescriptor getDescriptor()
          Used by OQLQuery to retrieve the class descriptor.
 QueryExpression getFinder()
           
 Persistence.FieldInfo[] getInfo()
          Returns FieldInfos for fields (excluding identifiers).
 QueryExpression getQueryExpression()
           
 java.lang.Object load(java.lang.Object conn, ProposedObject proposedObject, java.lang.Object identity, AccessMode accessMode)
          Loads the object from persistence storage.
 java.lang.String quoteName(java.lang.String name)
          Used by ParseTreeWalker to quote names in WHERE clause
 void setExtends(SQLEngine engine)
          Mutator method for setting extends SQLEngine
 java.lang.Object store(java.lang.Object conn, java.lang.Object[] fields, java.lang.Object identity, java.lang.Object[] original, java.lang.Object stamp)
          Stores the object in persistent storage, given the object fields and its identity.
 java.lang.String toString()
           
 void writeLock(java.lang.Object conn, java.lang.Object identity)
          Obtains a write lock on the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SQLEngine

SQLEngine(JDOClassDescriptor clsDesc,
          PersistenceFactory factory,
          java.lang.String stampField)
    throws MappingException
Throws:
MappingException
Method Detail

getColumnInfoForIdentities

public Persistence.ColumnInfo[] getColumnInfoForIdentities()
Description copied from interface: Persistence
Returns ColumnInfos for identifiers.

Specified by:
getColumnInfoForIdentities in interface Persistence
Returns:
An array of FieldInfo instances.

getInfo

public Persistence.FieldInfo[] getInfo()
Description copied from interface: Persistence
Returns FieldInfos for fields (excluding identifiers).

Specified by:
getInfo in interface Persistence
Returns:
An array of ColumnInfo instances.

setExtends

public void setExtends(SQLEngine engine)
Mutator method for setting extends SQLEngine

Parameters:
engine -

getDescriptor

public JDOClassDescriptor getDescriptor()
Used by OQLQuery to retrieve the class descriptor.

Returns:
the JDO class descriptor.

quoteName

public java.lang.String quoteName(java.lang.String name)
Used by ParseTreeWalker to quote names in WHERE clause

Parameters:
name - A name to be quoted
Returns:
a quoted name.

createQuery

public PersistenceQuery createQuery(QueryExpression query,
                                    java.lang.Class[] types,
                                    AccessMode accessMode)
                             throws QueryException
Description copied from interface: Persistence
Creates and returns a new query object. The query object is used to execute a query against persistent storage and fetch the results of the query. The query parameter types are specified prehand. If a particular parameter type is unknown, null may be used and type checking will defer to query execution.

Specified by:
createQuery in interface Persistence
Parameters:
query - The query expression
types - List of all parameter types, or null
Returns:
A new query object that can be executed
Throws:
QueryException - The query is invalid

createCall

public PersistenceQuery createCall(java.lang.String spCall,
                                   java.lang.Class[] types)

getQueryExpression

public QueryExpression getQueryExpression()

getFinder

public QueryExpression getFinder()

create

public java.lang.Object create(Database database,
                               java.lang.Object conn,
                               java.lang.Object[] fields,
                               java.lang.Object identity)
                        throws DuplicateIdentityException,
                               PersistenceException
Description copied from interface: Persistence
Creates a new object in persistence storage. Called for an object that was created during the transaction when the identity of that object is known. Creates a new record in persistence storage. Must detect an attempt to create an object with the same identity and must retain a lock on the object after creation. If the identity is null, an identity might be created and returned by this method.

Specified by:
create in interface Persistence
conn - An open connection
fields - The fields to store
identity - The object's identity
Returns:
The object's identity
Throws:
DuplicateIdentityException - An object with the same identity already exists in persistent storage
PersistenceException - A persistence error occured

store

public java.lang.Object store(java.lang.Object conn,
                              java.lang.Object[] fields,
                              java.lang.Object identity,
                              java.lang.Object[] original,
                              java.lang.Object stamp)
                       throws ObjectModifiedException,
                              ObjectDeletedException,
                              PersistenceException
Description copied from interface: Persistence
Stores the object in persistent storage, given the object fields and its identity. The object has been loaded before or has been created through a call to Persistence.create(org.exolab.castor.jdo.Database, java.lang.Object, java.lang.Object[], java.lang.Object). This method should detect whether the object has been modified in persistent storage since it was loaded. After this method returns all locks on the object must be retained until the transaction has completed. This method may return a new stamp to track further updates to the object.

If the object was not retrieved for exclusive access, this method will be asked to perform dirty checking prior to storing the object. The original argument will contains the object's original fields as retrieved in the transaction, and stamp the object's stamp returned from a successful call to Persistence.load(java.lang.Object, org.castor.persist.ProposedObject, java.lang.Object, org.exolab.castor.mapping.AccessMode). These arguments are null for objects retrieved with an exclusive lock.

Specified by:
store in interface Persistence
Parameters:
conn - An open connection
fields - The fields to store
identity - The object's identity
original - The original fields, or null
stamp - The object's stamp, or null
Returns:
The object's stamp, or null
Throws:
ObjectModifiedException - The object has been modified in persistence storage since it was last loaded
ObjectDeletedException - Indicates the object has been deleted from persistence storage
PersistenceException - A persistence error occured

delete

public void delete(java.lang.Object conn,
                   java.lang.Object identity)
            throws PersistenceException
Description copied from interface: Persistence
Deletes the object from persistent storage, given the object' identity. The object has been loaded before or has been created through a call to Persistence.create(org.exolab.castor.jdo.Database, java.lang.Object, java.lang.Object[], java.lang.Object). After this method returns all locks on the object must be retained until the transaction has completed.

Specified by:
delete in interface Persistence
Parameters:
conn - An open connection
identity - The object's identity
Throws:
PersistenceException - A persistence error occured

writeLock

public void writeLock(java.lang.Object conn,
                      java.lang.Object identity)
               throws ObjectDeletedException,
                      PersistenceException
Description copied from interface: Persistence
Obtains a write lock on the object. This method is called in order to lock the object and prevent concurrent access from other transactions. The object is known to have been loaded before either in this or another transaction. This method is used to assure that updates or deletion of the object will succeed when the transaction completes, without attempting to reload the object.

Specified by:
writeLock in interface Persistence
Parameters:
conn - An open connection
identity - The object's identity
Throws:
ObjectDeletedException - Indicates the object has been deleted from persistence storage
PersistenceException - A persistence error occured

load

public java.lang.Object load(java.lang.Object conn,
                             ProposedObject proposedObject,
                             java.lang.Object identity,
                             AccessMode accessMode)
                      throws ObjectNotFoundException,
                             PersistenceException
Loads the object from persistence storage. This method will load the object fields from persistence storage based on the object's identity. This method may return a stamp which can be used at a later point to determine whether the copy of the object in persistence storage is newer than the cached copy (see store(java.lang.Object, java.lang.Object[], java.lang.Object, java.lang.Object[], java.lang.Object)). If lock is true the object must be locked in persistence storage to prevent concurrent updates.

Specified by:
load in interface Persistence
Parameters:
conn - An open connection
fields - An Object[] to load field values into
identity - Identity of the object to load.
accessMode - The access mode (null equals shared)
Returns:
The object's stamp, or null
Throws:
ObjectNotFoundException - The object was not found in persistent storage
PersistenceException - A persistence error occured

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com