org.datanucleus.store.db4o.query
Class SQLQueryResult

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by org.datanucleus.store.query.AbstractQueryResult
              extended by org.datanucleus.store.db4o.query.SQLQueryResult
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable, java.util.Collection, java.util.List, org.datanucleus.store.query.QueryResult

public class SQLQueryResult
extends org.datanucleus.store.query.AbstractQueryResult

Result from an SQL query with db4o. Takes the sql4o result and converts it into the result format expected by JDO/JPA SQL definitions. Provides caching of results in this object, controlled by property "datanucleus.query.resultCacheType".

See Also:
Serialized Form

Field Summary
protected  int size
          Size of results, if known.
 
Fields inherited from class org.datanucleus.store.query.AbstractQueryResult
closed, connectionListeners, LOCALISER, query, resultSizeMethod
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SQLQueryResult(org.datanucleus.store.query.Query query, com.db4o.ObjectContainer cont, org.datanucleus.sql4o.ObjectSetWrapper results, org.datanucleus.metadata.QueryResultMetaData resultMetaData)
          Constructor.
 
Method Summary
 void close()
          Close the results and free off any resources held.
protected  void closeResults()
          Internal method to close the ResultSet.
protected  void closingConnection()
          Inform the query result that the connection is being closed so perform any operations now, or rest in peace.
 boolean equals(java.lang.Object o)
          Equality operator for QueryResults.
 java.lang.Object get(int index)
           
protected  java.lang.Object getObjectForIndex(int index)
          Accessor for the result object at an index.
protected  java.lang.Object getRowForCandidateClass(int index)
          Accessor for the row object(s) when there is a candidate class.
protected  java.lang.Object getRowForNoCandidateClass(int index)
          Accessor for the row object(s) when there is no candidate class.
protected  java.lang.Object getRowForResultClass(int index)
          Method to prepare results when there is a result class.
protected  java.lang.Object getRowForResultMetaData(int index)
          Accessor for the row object(s) when there is metadata defining the result.
 java.util.Iterator iterator()
          Accessor for an iterator for the results.
 java.util.ListIterator listIterator()
          Accessor for an iterator for the results.
protected  void prepareObjectForUse(java.lang.Object obj, com.db4o.ObjectContainer cont)
           
 int size()
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] arg0)
           
 
Methods inherited from class org.datanucleus.store.query.AbstractQueryResult
add, add, addAll, addConnectionListener, assertIsOpen, clear, contains, containsAll, disconnect, getSizeUsingMethod, hashCode, indexOf, isEmpty, isOpen, lastIndexOf, remove, set, subList
 
Methods inherited from class java.util.AbstractList
listIterator, removeRange
 
Methods inherited from class java.util.AbstractCollection
addAll, remove, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
addAll, remove, removeAll, retainAll
 
Methods inherited from interface java.util.List
addAll, remove, removeAll, retainAll
 

Field Detail

size

protected int size
Size of results, if known. -1 otherwise.

Constructor Detail

SQLQueryResult

public SQLQueryResult(org.datanucleus.store.query.Query query,
                      com.db4o.ObjectContainer cont,
                      org.datanucleus.sql4o.ObjectSetWrapper results,
                      org.datanucleus.metadata.QueryResultMetaData resultMetaData)
Constructor.

Parameters:
query - Query being executed
cont - Object Container in use
results - The results from sql4o
Method Detail

close

public void close()
Close the results and free off any resources held.

Specified by:
close in interface org.datanucleus.store.query.QueryResult
Overrides:
close in class org.datanucleus.store.query.AbstractQueryResult

closeResults

protected void closeResults()
Internal method to close the ResultSet.

Specified by:
closeResults in class org.datanucleus.store.query.AbstractQueryResult

closingConnection

protected void closingConnection()
Inform the query result that the connection is being closed so perform any operations now, or rest in peace.

Specified by:
closingConnection in class org.datanucleus.store.query.AbstractQueryResult

equals

public boolean equals(java.lang.Object o)
Equality operator for QueryResults. Overrides the AbstractList implementation since that uses size() and iterator() and that would cause problems when closed.

Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.List
Specified by:
equals in class org.datanucleus.store.query.AbstractQueryResult
Parameters:
o - The object to compare against
Returns:
Whether they are equal

iterator

public java.util.Iterator iterator()
Accessor for an iterator for the results.

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.List
Specified by:
iterator in class org.datanucleus.store.query.AbstractQueryResult
Returns:
The iterator

listIterator

public java.util.ListIterator listIterator()
Accessor for an iterator for the results.

Specified by:
listIterator in interface java.util.List
Specified by:
listIterator in class org.datanucleus.store.query.AbstractQueryResult
Returns:
The iterator

getObjectForIndex

protected java.lang.Object getObjectForIndex(int index)
Accessor for the result object at an index. If the object has already been processed will return that object, otherwise will retrieve the object using the factory.

Parameters:
index - The list index position
Returns:
The result object

getRowForResultMetaData

protected java.lang.Object getRowForResultMetaData(int index)
Accessor for the row object(s) when there is metadata defining the result. Each row of results should follow the result metadata (JPA).

Parameters:
index - Row index
Returns:
The row in the required form

getRowForCandidateClass

protected java.lang.Object getRowForCandidateClass(int index)
Accessor for the row object(s) when there is a candidate class. Each row of results should be of candidate type.

Parameters:
index - Row index
Returns:
The row in the required form

getRowForResultClass

protected java.lang.Object getRowForResultClass(int index)
Method to prepare results when there is a result class. Each row of results should be an instance of ResultClass.

Parameters:
index - The row number
Returns:
The results in the required form

getRowForNoCandidateClass

protected java.lang.Object getRowForNoCandidateClass(int index)
Accessor for the row object(s) when there is no candidate class. Each row of results should be of the form Object (when 1 column) or Object[] (when multiple).

Parameters:
index - Row index
Returns:
The row in the required form

prepareObjectForUse

protected void prepareObjectForUse(java.lang.Object obj,
                                   com.db4o.ObjectContainer cont)

get

public java.lang.Object get(int index)
Specified by:
get in interface java.util.List
Specified by:
get in class org.datanucleus.store.query.AbstractQueryResult

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List
Overrides:
size in class org.datanucleus.store.query.AbstractQueryResult

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List
Overrides:
toArray in class org.datanucleus.store.query.AbstractQueryResult

toArray

public java.lang.Object[] toArray(java.lang.Object[] arg0)
Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List
Overrides:
toArray in class org.datanucleus.store.query.AbstractQueryResult


Copyright © 2010. All Rights Reserved.