localFields.addElement(getDescriptor().getInheritancePolicy().getClassIndicatorField());
}
//Add attribute fields
for(Iterator it = getPartialAttributeExpressions().iterator();it.hasNext();){
Expression expression = (Expression)it.next();
if (expression.isQueryKeyExpression()) {
((QueryKeyExpression)expression).getBuilder().setSession(session.getRootSession(null));
((QueryKeyExpression)expression).getBuilder().setQueryClass(getDescriptor().getJavaClass());
DatabaseMapping mapping = ((QueryKeyExpression)expression).getMapping();
if (!((QueryKeyExpression)expression).getBaseExpression().isExpressionBuilder()) {
if(foreignFields==null){
foreignFields = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
}
if(!isCustomSQL){
foreignFields.add(expression);
}else{
foreignFields.addAll(expression.getFields());
}
}else{
if (mapping == null) {
throw QueryException.specifiedPartialAttributeDoesNotExist(this, expression.getName(), descriptor.getJavaClass().getName());
}
if(mapping.isForeignReferenceMapping() ){
if(foreignFields==null){
foreignFields = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
}
if(!isCustomSQL){
foreignFields.add(expression);
}else{
foreignFields.addAll(expression.getFields());
}
}else{
localFields.addAll(expression.getFields());
}
}
} else {
throw QueryException.expressionDoesNotSupportPartialAttributeReading(expression);
}