org.exolab.castor.persist
Class QueryResults

java.lang.Object
  extended by org.exolab.castor.persist.QueryResults

public final class QueryResults
extends java.lang.Object

The result of a query in the context of a transaction. A query is executed against the cache engine in the context of a transaction. The result of a query is this object that can be used to obtain the next object in the query.

Version:
$Revision: 1.3 $ $Date: 2005/07/15 21:59:15 $
Author:
Assaf Arkin

Constructor Summary
QueryResults(TransactionContext tx, LockEngine engine, PersistenceQuery query, AccessMode accessMode, Database db)
           
 
Method Summary
 boolean absolute(int row)
           
 void close()
          Close the query and release all resources held by the query.
 java.lang.Object fetch()
          Loads the specified object with the identity.
 PersistenceQuery getQuery()
          Returns the associated query.
 java.lang.Class getResultType()
          Returns the type of object returned by this query.
 TransactionContext getTransaction()
          Returns the transaction context in which this query was opened.
 java.lang.Object nextIdentity()
          Returns the identity of the next object to be returned.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryResults

public QueryResults(TransactionContext tx,
                    LockEngine engine,
                    PersistenceQuery query,
                    AccessMode accessMode,
                    Database db)
Method Detail

getTransaction

public TransactionContext getTransaction()
Returns the transaction context in which this query was opened. The transaction may be closed.

Returns:
The query's transaction context

getQuery

public PersistenceQuery getQuery()
Returns the associated query.

Returns:
The query

getResultType

public java.lang.Class getResultType()
Returns the type of object returned by this query.

Returns:
The type of object returned by this query

nextIdentity

public java.lang.Object nextIdentity()
                              throws TransactionNotInProgressException,
                                     PersistenceException
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.

Returns:
The identity of the next object
Throws:
PersistenceException - An error reported by the persistence engine
TransactionNotInProgressException - The transaction has been closed

fetch

public java.lang.Object fetch()
                       throws TransactionNotInProgressException,
                              PersistenceException,
                              ObjectNotFoundException,
                              LockNotGrantedException
Loads the specified object with the identity. The identity must have been retrieved with a call to nextIdentity().

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.

If the object has been deleted in this transaction, this method will report an ObjectNotFoundException. However, the caller may iterate to and obtain the next object.

This method is equivalent to TransactionContext.fetch(org.exolab.castor.persist.LockEngine, org.exolab.castor.persist.ClassMolder, java.lang.Object, org.exolab.castor.mapping.AccessMode) with a know cache engine, identity and lock and acts on the query results rather than issuing a new query to load the object.

Returns:
The loaded object
Throws:
ObjectNotFoundException - The object was not found in persistent storage
LockNotGrantedException - Could not acquire a lock on the object
PersistenceException - An error reported by the persistence engine
TransactionNotInProgressException - The transaction has been closed

close

public void close()
Close the query and release all resources held by the query.


absolute

public boolean absolute(int row)
                 throws PersistenceException
Throws:
PersistenceException

size

public int size()
         throws PersistenceException
Throws:
PersistenceException


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