throws ClassNotPersistenceCapableException, PersistenceBrokerException
{
if (log.isDebugEnabled()) log.debug("getCollectionByQuery (" + collectionClass + ", " + itemClass + ", " + query + ")");
ClassDescriptor cld = pb.getClassDescriptor(itemClass);
ManageableCollection result = null;
OJBIterator iter = null;
boolean isRetrievalTasksCreated = (batchRetrieval && (m_retrievalTasks == null));
int fullSize = -1;
int size = 0;
if (isRetrievalTasksCreated)
{
// Maps ReferenceDescriptors to HashSets of owners
m_retrievalTasks = new HashMap();
}
try
{
result = (ManageableCollection) collectionClass.newInstance();
// now iterate over all elements and add them to the new collection
iter = pb.getIteratorFromQuery(query, cld);
// BRJ : get fullSizefor Query
// to be removed when Query.fullSize is removed
if (iter instanceof PagingIterator)
{
fullSize = iter.fullSize();
}
while (iter.hasNext())
{
Object candidate = iter.next();
/**
* MBAIRD
* candidate CAN be null in the case of materializing from an iterator based
* on a query for a class that is mapped to a table that has other classes
* mapped to that table as well, but aren't extents.
*/
if (candidate != null)
{
IndirectionHandler handler = ProxyHelper.getIndirectionHandler(candidate);
if ((handler != null)
|| itemClass.isAssignableFrom(candidate.getClass()))
{
result.ojbAdd(candidate);
// BRJ: count added objects
// to be removed when Query.fullSize is removed
size++;
}