* This must use two selects, the first retrieves the type field only.
*/
protected AbstractRecord selectOneRowUsingDefaultMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException {
// Get the row for the given class indicator field
// The indicator select is prepared in the original query, so can just be executed.
AbstractRecord typeRow = ((ExpressionQueryMechanism)query.getQueryMechanism()).selectOneRowFromTable();
if (typeRow == null) {
return null;
}
Class concreteClass = classFromRow(typeRow, query.getSession());
ClassDescriptor concreteDescriptor = getDescriptor(concreteClass);
if (concreteDescriptor == null) {
throw QueryException.noDescriptorForClassFromInheritancePolicy(query, concreteClass);
}
ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone();
concreteQuery.setReferenceClass(concreteClass);
concreteQuery.setDescriptor(concreteDescriptor);
AbstractRecord resultRow = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable();
return resultRow;
}