org.exolab.castor.jdo.drivers
Class PostgreSQLCallQuery

java.lang.Object
  extended by org.exolab.castor.jdo.drivers.PostgreSQLCallQuery
All Implemented Interfaces:
PersistenceQuery

final class PostgreSQLCallQuery
extends java.lang.Object
implements PersistenceQuery

PersistenceQuery implementation for use with PostgreSQL stored functions returning instance, which can be fetched only through SELECT of fields of the instance.

Version:
$Revision: 1.5 $ $Date: 2005/07/15 21:59:16 $
Author:
Rostislav Beloff, Oleg Nitz

Constructor Summary
PostgreSQLCallQuery(java.lang.String call, java.lang.Class[] types, java.lang.Class javaClass, java.lang.String[] fields, int[] sqlTypes)
           
 
Method Summary
 boolean absolute(int row)
          moves the result of the query to the absolute position in the resultset
 void close()
          Close the query and release all resources held by the query.
 void execute(java.lang.Object conn, AccessMode accessMode)
          Execute the query with the give connection and lock type.
 void execute(java.lang.Object conn, AccessMode accessMode, boolean scrollable)
          same as above, but parameterized for scrollable resultsets.
 java.lang.Object fetch(ProposedObject proposedObject, java.lang.Object identity)
          Loades the object.
 int getParameterCount()
          Returns the number of parameters required for this query.
 java.lang.Class getParameterType(int index)
          Returns the type of a parameter required by this query.
 java.lang.Class getResultType()
          Returns the type of object returned by this query.
 java.lang.Object nextIdentity(java.lang.Object identity)
          Returns the identity of the next object to be returned.
 void setParameter(int index, java.lang.Object value)
          Sets the value of a paramter.
 int size()
          finds the size of the resulting resultset from the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostgreSQLCallQuery

PostgreSQLCallQuery(java.lang.String call,
                    java.lang.Class[] types,
                    java.lang.Class javaClass,
                    java.lang.String[] fields,
                    int[] sqlTypes)
Method Detail

absolute

public boolean absolute(int row)
                 throws PersistenceException
Description copied from interface: PersistenceQuery
moves the result of the query to the absolute position in the resultset

Specified by:
absolute in interface PersistenceQuery
Parameters:
row - The row to move to
Throws:
PersistenceException - A persistence error occured

size

public int size()
         throws PersistenceException
Description copied from interface: PersistenceQuery
finds the size of the resulting resultset from the query.

Specified by:
size in interface PersistenceQuery
Throws:
PersistenceException

getParameterCount

public int getParameterCount()
Description copied from interface: PersistenceQuery
Returns the number of parameters required for this query.

Specified by:
getParameterCount in interface PersistenceQuery
Returns:
Number of query parameters

getParameterType

public java.lang.Class getParameterType(int index)
                                 throws java.lang.ArrayIndexOutOfBoundsException
Description copied from interface: PersistenceQuery
Returns the type of a parameter required by this query. May return null if the type is unknown.

Specified by:
getParameterType in interface PersistenceQuery
Parameters:
index - The parameter index
Returns:
Type of parameter, or null
Throws:
java.lang.ArrayIndexOutOfBoundsException

setParameter

public void setParameter(int index,
                         java.lang.Object value)
                  throws java.lang.ArrayIndexOutOfBoundsException,
                         java.lang.IllegalArgumentException
Description copied from interface: PersistenceQuery
Sets the value of a paramter. Will complain if the parameter is not of the specified type.

Specified by:
setParameter in interface PersistenceQuery
Parameters:
index - The parameter index
value - The parameter value
Throws:
java.lang.ArrayIndexOutOfBoundsException
java.lang.IllegalArgumentException

getResultType

public java.lang.Class getResultType()
Description copied from interface: PersistenceQuery
Returns the type of object returned by this query.

Specified by:
getResultType in interface PersistenceQuery
Returns:
The type of object returned by this query

execute

public void execute(java.lang.Object conn,
                    AccessMode accessMode,
                    boolean scrollable)
             throws QueryException,
                    PersistenceException
Description copied from interface: PersistenceQuery
same as above, but parameterized for scrollable resultsets.

Specified by:
execute in interface PersistenceQuery
Parameters:
conn - An open connection
accessMode - The access mode (null equals shared)
scrollable - The db cursor mode.
Throws:
QueryException - An invalid query
PersistenceException - An error reported by the persistence engine

execute

public void execute(java.lang.Object conn,
                    AccessMode accessMode)
             throws QueryException,
                    PersistenceException
Description copied from interface: PersistenceQuery
Execute the query with the give connection and lock type. After a successful return the query results will be returned by calling PersistenceQuery.nextIdentity(java.lang.Object) and PersistenceQuery.fetch(org.castor.persist.ProposedObject, java.lang.Object). The query parameters will be reset. A new query may be issued by providing new query parameters and calling PersistenceQuery.execute(Object, AccessMode).

Specified by:
execute in interface PersistenceQuery
Parameters:
conn - An open connection
accessMode - The access mode (null equals shared)
Throws:
QueryException - An invalid query
PersistenceException - An error reported by the persistence engine

nextIdentity

public java.lang.Object nextIdentity(java.lang.Object identity)
                              throws PersistenceException
Description copied from interface: PersistenceQuery
Returns 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:
nextIdentity in interface PersistenceQuery
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

close

public void close()
Description copied from interface: PersistenceQuery
Close the query and release all resources held by the query.

Specified by:
close in interface PersistenceQuery

fetch

public java.lang.Object fetch(ProposedObject proposedObject,
                              java.lang.Object identity)
                       throws ObjectNotFoundException,
                              PersistenceException
Description copied from interface: PersistenceQuery
Loades the object. This method must be called immediately after PersistenceQuery.nextIdentity(java.lang.Object) 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.ProposedObject, java.lang.Object, 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:
fetch in interface PersistenceQuery
identity - The object's identity
Returns:
The object's stamp, or null
Throws:
ObjectNotFoundException - The object was not found in persistent storage
PersistenceException - A persistence error occured
See Also:
Persistence.load(java.lang.Object, org.castor.persist.ProposedObject, java.lang.Object, org.exolab.castor.mapping.AccessMode)


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