return null;
} else {
throw QueryException.nullPrimaryKeyInBuildingObject(query, databaseRow);
}
}
ClassDescriptor concreteDescriptor = getDescriptor();
if (concreteDescriptor.hasInheritance() && concreteDescriptor.getInheritancePolicy().shouldReadSubclasses()) {
Class classValue = concreteDescriptor.getInheritancePolicy().classFromRow(databaseRow, session);
concreteDescriptor = session.getDescriptor(classValue);
if ((concreteDescriptor == null) && query.hasPartialAttributeExpressions()) {
concreteDescriptor = getDescriptor();
}
if (concreteDescriptor == null) {
// Profile object building.
session.endOperationProfile(SessionProfiler.OBJECT_BUILDING);
throw QueryException.noDescriptorForClassFromInheritancePolicy(query, classValue);
}
}
Object domainObject = null;
try {
if (session.isUnitOfWork()) {
// Do not wrap yet if in UnitOfWork, as there is still much more
// processing ahead.
domainObject = buildObjectInUnitOfWork(query, joinManager, databaseRow, (UnitOfWorkImpl)session, primaryKey, concreteDescriptor);
} else {
domainObject = buildObject(query, databaseRow, session, primaryKey, concreteDescriptor, joinManager);
// wrap the object if the query requires it.
if (query.shouldUseWrapperPolicy()) {
domainObject = concreteDescriptor.getObjectBuilder().wrapObject(domainObject, session);
}
}
} finally {
session.endOperationProfile(SessionProfiler.OBJECT_BUILDING);
}