{
//Not found
return new InstanceArrayList(0);
}
LockableFile directFile = new LockableFile(dataFile);
//BLOCKING
directFile.lock(true);
try
{
Instance instance = m_context.findInstance(query.getMetaclass(), oid);
if (instance == null)
{
instance = new Instance(query.getMetaclass(), m_context);
instance.cache(oid);
}
for (Iterator i = query.getFieldIterator(); i.hasNext(); )
{
Field field = (Field)i.next();
Attribute attribute = field.getAttribute();
FilePrimitiveMapping primitiveMapping = (FilePrimitiveMapping)query.getPersistenceMapping().getAttributeMapping(attribute);
switch (primitiveMapping.getSysId())
{
case FilePrimitiveMapping.SYSID_ID:
instance.setOldValueDirect(attribute.getOrdinal(), oid.getValue(0));
break;
case FilePrimitiveMapping.SYSID_DATA:
Object value = null;
try
{
value = (primitiveMapping.getAttribute().getType() == Primitive.STRING) ?
(Object)directFile.getDataAsString() : directFile.getDataAsBinary();
}
catch (IOException ex)
{
throw new PersistenceException("err.persistence.file.io", ex);
}
instance.setOldValueDirect(attribute.getOrdinal(), value);
break;
case FilePrimitiveMapping.SYSID_LOCKING:
instance.setOldValueDirect(attribute.getOrdinal(),
Primitive.createLong(dataFile.lastModified()) );
break;
}
}
InstanceArrayList result = new InstanceArrayList(1);
result.add(instance);
return result;
}
finally
{
if (directFile != null)
{
directFile.unlock();
directFile.close();
}
}
}