use of org.apache.cayenne.query.DefaultEmbeddableResultSegment in project cayenne by apache.
the class SQLResult method getResolvedComponents.
public List<Object> getResolvedComponents(EntityResolver resolver) {
if (resultDescriptors == null) {
return Collections.emptyList();
}
List<Object> resolvedComponents = new ArrayList<>(resultDescriptors.size());
int offset = 0;
for (Object component : getComponents()) {
if (component instanceof String) {
resolvedComponents.add(new DefaultScalarResultSegment((String) component, offset));
offset = offset + 1;
} else if (component instanceof EntityResult) {
EntityResult entityResult = (EntityResult) component;
Map<String, String> fields = entityResult.getDbFields(resolver);
String entityName = entityResult.getEntityName();
if (entityName == null) {
entityName = resolver.getObjEntity(entityResult.getEntityClass()).getName();
}
ClassDescriptor classDescriptor = resolver.getClassDescriptor(entityName);
resolvedComponents.add(new DefaultEntityResultSegment(classDescriptor, fields, offset));
offset = offset + fields.size();
} else if (component instanceof EmbeddedResult) {
EmbeddedResult embeddedResult = (EmbeddedResult) component;
Map<String, String> fields = embeddedResult.getFields();
resolvedComponents.add(new DefaultEmbeddableResultSegment(embeddedResult.getEmbeddable(), fields, offset));
offset = offset + fields.size();
} else {
throw new IllegalArgumentException("Unsupported result descriptor component: " + component);
}
}
return resolvedComponents;
}
Aggregations