//obtain current ODMG transaction
Transaction tx = TxManagerFactory.instance().getTransaction();
// create PBCapsule
PBCapsule capsule = null;
ManageableCollection result = null;
try
{
capsule = new PBCapsule(pbKey, tx);
PersistenceBroker broker = capsule.getBroker();
// ask the broker to perfom the query.
// the concrete result type is configurable
if (!(query instanceof ReportQuery))
{
result = broker.getCollectionByQuery(this.getCollectionClass(), query);
performLockingIfRequired(tx, broker, result);
}
else
{
Iterator iter = null;
result = new ManageableArrayList();
iter = broker.getReportQueryIteratorByQuery(query);
try
{
while (iter.hasNext())
{
Object[] res = (Object[]) iter.next();
if (res.length == 1)
{
if (res[0] != null) // skip null values
{
result.ojbAdd(res[0]);
}
}
else
{
// skip null tuples
for (int i = 0; i < res.length; i++)
{
if (res[i] != null)
{
result.ojbAdd(res);
break;
}
}
}
}