Search in sources :

Example 1 with EmbeddableResultSegment

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();
        }
    }
}
Also used : EmbeddableResultSegment(org.apache.cayenne.query.EmbeddableResultSegment) ArrayList(java.util.ArrayList) List(java.util.List) EmbeddableObject(org.apache.cayenne.EmbeddableObject) EntityResultSegment(org.apache.cayenne.query.EntityResultSegment)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 EmbeddableObject (org.apache.cayenne.EmbeddableObject)1 EmbeddableResultSegment (org.apache.cayenne.query.EmbeddableResultSegment)1 EntityResultSegment (org.apache.cayenne.query.EntityResultSegment)1