Package org.exolab.castor.jdo.engine
Class SQLEngine
java.lang.Object
org.exolab.castor.jdo.engine.SQLEngine
- All Implemented Interfaces:
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: 8762 $ $Date: 2006-04-26 16:24:34 -0600 (Wed, 26 Apr 2006) $
- Author:
- Assaf Arkin, Thomas Yip, Bruce Snyder, Werner Guttmann, Ralf Joachim
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate
(Database database, Object conn, ProposedEntity entity, Identity identity) Creates a new object in persistence storage.createCall
(String spCall, Class[] types) createQuery
(QueryExpression query, Class[] types, AccessMode accessMode) Creates and returns a new query object.createSQLRelationLoader
(String manyTable, String[] idSQL, int[] idType, TypeConvertor[] idTo, TypeConvertor[] idFrom, String[] relatedIdSQL, int[] relatedIdType, TypeConvertor[] ridTo, TypeConvertor[] ridFrom) void
Deletes the object from persistent storage, given the object' identity.Used byOQLQuery
to retrieve the class descriptor.getInfo()
protected Object
void
load
(Object conn, ProposedEntity entity, Identity identity, AccessMode accessMode) Loads the object from persistence storage.void
setExtends
(SQLEngine engine) Mutator method for setting extends SQLEngine.void
store
(Object conn, Identity identity, ProposedEntity newentity, ProposedEntity oldentity) Stores the object in persistent storage, given the object fields and its identity.protected Object
toString()
-
Constructor Details
-
SQLEngine
- Throws:
MappingException
-
-
Method Details
-
createSQLRelationLoader
public SQLRelationLoader createSQLRelationLoader(String manyTable, String[] idSQL, int[] idType, TypeConvertor[] idTo, TypeConvertor[] idFrom, String[] relatedIdSQL, int[] relatedIdType, TypeConvertor[] ridTo, TypeConvertor[] ridFrom) - Specified by:
createSQLRelationLoader
in interfacePersistence
-
getColumnInfoForIdentities
-
getInfo
-
setExtends
Mutator method for setting extends SQLEngine.- Parameters:
engine
-
-
getExtends
-
getDescriptor
Used byOQLQuery
to retrieve the class descriptor.- Returns:
- the JDO class descriptor.
-
createQuery
public PersistenceQuery createQuery(QueryExpression query, 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 interfacePersistence
- Parameters:
query
- The query expressiontypes
- List of all parameter types, or null- Returns:
- A new query object that can be executed
- Throws:
QueryException
- The query is invalid
-
createCall
-
getQueryExpression
-
getFinder
-
getTableInfo
-
idToJava
-
toJava
-
create
public Identity create(Database database, Object conn, ProposedEntity entity, Identity identity) throws 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 interfacePersistence
- Parameters:
conn
- An open connectionentity
- The fields to storeidentity
- The object's identity- Returns:
- The object's identity
- Throws:
PersistenceException
- An object with the same identity already exists in persistent storage or any other persistence error occured.
-
store
public void store(Object conn, Identity identity, ProposedEntity newentity, ProposedEntity oldentity) throws 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 toPersistence.create(org.exolab.castor.jdo.Database, java.lang.Object, org.castor.persist.ProposedEntity, org.exolab.castor.persist.spi.Identity)
. 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.ProposedEntity, org.exolab.castor.persist.spi.Identity, org.exolab.castor.mapping.AccessMode)
. These arguments are null for objects retrieved with an exclusive lock.- Specified by:
store
in interfacePersistence
- Parameters:
conn
- An open connectionidentity
- The object's identitynewentity
- The fields to storeoldentity
- The original fields, or null- Throws:
PersistenceException
- The object has been modified in persistence storage since it was last loaded or has been deleted from persitence storage or any other persistence error occored.
-
delete
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 toPersistence.create(org.exolab.castor.jdo.Database, java.lang.Object, org.castor.persist.ProposedEntity, org.exolab.castor.persist.spi.Identity)
. After this method returns all locks on the object must be retained until the transaction has completed.- Specified by:
delete
in interfacePersistence
- Parameters:
conn
- An open connectionidentity
- The object's identity- Throws:
PersistenceException
- A persistence error occured
-
load
public void load(Object conn, ProposedEntity entity, Identity identity, AccessMode accessMode) throws 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 (seestore(java.lang.Object, org.exolab.castor.persist.spi.Identity, org.castor.persist.ProposedEntity, org.castor.persist.ProposedEntity)
). If lock is true the object must be locked in persistence storage to prevent concurrent updates.- Specified by:
load
in interfacePersistence
- Parameters:
conn
- An open connectionentity
- An Object[] to load field values intoidentity
- Identity of the object to load.accessMode
- The access mode (null equals shared)- Throws:
PersistenceException
- A persistence error occured
-
toString
-