Package org.exolab.castor.persist.spi
Class AbstractCallQuery
- java.lang.Object
-
- org.exolab.castor.persist.spi.AbstractCallQuery
-
- All Implemented Interfaces:
PersistenceQuery
- Direct Known Subclasses:
MultiRSCallQuery,ReturnedRSCallQuery
public abstract class AbstractCallQuery extends java.lang.Object implements PersistenceQuery
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCallQuery(java.lang.String call, java.lang.Class<?>[] types, java.lang.Class<?> javaClass, int[] sqlTypes)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanabsolute(int row)Moves the result of the query to the absolute position in the resultset.voidclose()Close the query and release all resources held by the query.protected abstract voidexecute(java.lang.Object conn, AccessMode accessMode)voidexecute(java.lang.Object conn, AccessMode accessMode, boolean scrollable)Execute the query with the give connection and lock type.voidfetch(ProposedEntity proposedObject)Loades the object.intgetParameterCount()java.lang.Class<?>getParameterType(int index)java.lang.Class<?>getResultType()Returns the type of object returned by this query.IdentitynextIdentity(Identity identity)Returns the identity of the next object to be returned.protected abstract booleannextRow()voidsetParameter(int index, java.lang.Object value)Sets the value of a paramter.intsize()Finds the size of the resulting resultset from the query.
-
-
-
Field Detail
-
_stmt
protected java.sql.PreparedStatement _stmt
-
_rs
protected java.sql.ResultSet _rs
-
_lastIdentity
protected Identity _lastIdentity
-
_values
protected final java.lang.Object[] _values
-
_call
protected final java.lang.String _call
-
-
Method Detail
-
nextRow
protected abstract boolean nextRow() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
fetch
public void fetch(ProposedEntity proposedObject) throws PersistenceException
Description copied from interface:PersistenceQueryLoades the object. This method must be called immediately afterPersistenceQuery.nextIdentity(org.exolab.castor.persist.spi.Identity)with the same identity.If the object is locked by another transaction this method will block until the lock is released, or a timeout occured. If a timeout occurs or the object has been deleted by the other transaction, this method will report an
ObjectNotFoundException. The query may proceed to the next identity.This method is equivalent to
Persistence.load(java.lang.Object, org.castor.persist.ProposedEntity, org.exolab.castor.persist.spi.Identity, org.exolab.castor.mapping.AccessMode)with a known cache engine and access mode and acts on the query results rather than issuing a new query to load the object.- Specified by:
fetchin interfacePersistenceQuery- Parameters:
proposedObject- The fields to load into- Throws:
PersistenceException- The object was not found in persistent storage or any other persistence error occured.- See Also:
Persistence.load(java.lang.Object, org.castor.persist.ProposedEntity, org.exolab.castor.persist.spi.Identity, org.exolab.castor.mapping.AccessMode)
-
close
public void close()
Description copied from interface:PersistenceQueryClose the query and release all resources held by the query.- Specified by:
closein interfacePersistenceQuery
-
getParameterCount
public int getParameterCount()
-
getParameterType
public java.lang.Class<?> getParameterType(int index) throws java.lang.ArrayIndexOutOfBoundsException- Throws:
java.lang.ArrayIndexOutOfBoundsException
-
setParameter
public void setParameter(int index, java.lang.Object value) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.IllegalArgumentExceptionDescription copied from interface:PersistenceQuerySets the value of a paramter. Will complain if the parameter is not of the specified type.- Specified by:
setParameterin interfacePersistenceQuery- Parameters:
index- The parameter indexvalue- The parameter value- Throws:
java.lang.ArrayIndexOutOfBoundsExceptionjava.lang.IllegalArgumentException
-
absolute
public boolean absolute(int row) throws PersistenceExceptionDescription copied from interface:PersistenceQueryMoves the result of the query to the absolute position in the resultset.- Specified by:
absolutein interfacePersistenceQuery- Parameters:
row- The row to move to- Throws:
PersistenceException- A persistence error occured
-
size
public int size() throws PersistenceExceptionDescription copied from interface:PersistenceQueryFinds the size of the resulting resultset from the query.- Specified by:
sizein interfacePersistenceQuery- Throws:
PersistenceException
-
getResultType
public java.lang.Class<?> getResultType()
Description copied from interface:PersistenceQueryReturns the type of object returned by this query.- Specified by:
getResultTypein interfacePersistenceQuery- Returns:
- The type of object returned by this query
-
execute
public void execute(java.lang.Object conn, AccessMode accessMode, boolean scrollable) throws PersistenceExceptionDescription copied from interface:PersistenceQueryExecute the query with the give connection and lock type. After a successful return the query results will be returned by callingPersistenceQuery.nextIdentity(org.exolab.castor.persist.spi.Identity)andPersistenceQuery.fetch(org.castor.persist.ProposedEntity). The query parameters will be reset. A new query may be issued by providing new query parameters and callingPersistenceQuery.execute(Object, AccessMode, boolean).- Specified by:
executein interfacePersistenceQuery- Parameters:
conn- An open connectionaccessMode- The access mode (null equals shared)scrollable- The db cursor mode.- Throws:
PersistenceException- An invalid query or an error reported by the persistence engine.
-
execute
protected abstract void execute(java.lang.Object conn, AccessMode accessMode) throws PersistenceException- Throws:
PersistenceException
-
nextIdentity
public Identity nextIdentity(Identity identity) throws PersistenceException
Description copied from interface:PersistenceQueryReturns the identity of the next object to be returned. Calling this method multiple time will skip objects. When the result set has been exhuasted, this method will return null.- Specified by:
nextIdentityin interfacePersistenceQuery- Parameters:
identity- The identity of the previous object, null if this method is called for the first time- Returns:
- The identity of the next object, null if the result set has been exhausted
- Throws:
PersistenceException- An error reported by the persistence engine
-
-