use of org.apache.cayenne.query.EmbeddableResultSegment in project cayenne by apache.
the class DataDomainQueryAction method interceptObjectConversion.
@SuppressWarnings("unchecked")
private void interceptObjectConversion() {
if (context != null) {
// List<DataRow> or List<Object[]>
List mainRows = response.firstList();
if (mainRows != null && !mainRows.isEmpty()) {
ObjectConversionStrategy<?> converter;
if (metadata.isFetchingDataRows()) {
converter = new IdentityConversionStrategy();
} else {
List<Object> rsMapping = metadata.getResultSetMapping();
if (rsMapping == null) {
converter = new SingleObjectConversionStrategy();
} else {
if (metadata.isSingleResultSetMapping()) {
if (rsMapping.get(0) instanceof EntityResultSegment) {
converter = new SingleObjectConversionStrategy();
} else if (rsMapping.get(0) instanceof EmbeddableResultSegment) {
converter = new SingleEmbeddableConversionStrategy();
} else {
converter = new SingleScalarConversionStrategy();
}
} else {
converter = new MixedConversionStrategy();
}
}
}
if (metadata.getResultMapper() != null) {
converter = new MapperConversionStrategy(converter);
}
converter.convert(mainRows);
// rewind response after firstList() call
response.reset();
}
}
}
Aggregations