Examples of SqlResultSetMapping


Examples of org.apache.cayenne.query.SQLResultSetMapping

    /**
     * Returns a positional EntityResult, incrementing position index on each call.
     */
    EntityResult nextEntityResult() {

        SQLResultSetMapping resultSetMapping = compiledExpression.getResultSetMapping();
        if (resultSetMapping == null) {
            throw new EJBQLException(
                    "No result set mapping exists for expression, can't map EntityResult");
        }

        return resultSetMapping.getEntityResult(resultDescriptorPosition++);
    }
View Full Code Here

Examples of org.apache.cayenne.query.SQLResultSetMapping

    /**
     * Returns a positional column alias, incrementing position index on each call.
     */
    String nextColumnAlias() {

        SQLResultSetMapping resultSetMapping = compiledExpression.getResultSetMapping();
        if (resultSetMapping == null) {
            throw new EJBQLException(
                    "No result set mapping exists for expression, can't map column aliases");
        }

        return resultSetMapping.getColumnResult(resultDescriptorPosition++);
    }
View Full Code Here

Examples of org.apache.cayenne.query.SQLResultSetMapping

            List<DataRow> mainRows = response.firstList();
            if (mainRows != null && !mainRows.isEmpty()) {

                ObjectConversionStrategy converter;

                SQLResultSetMapping rsMapping = metadata.getResultSetMapping();
                if (rsMapping == null) {
                    converter = new SingleObjectConversionStrategy();
                }
                else {

                    int entityResultCount = 0;
                    int columnResultCount = 0;
                    for (Object result : rsMapping.getResultDescriptors()) {
                        if (result instanceof String) {
                            columnResultCount++;
                        }
                        else {
                            entityResultCount++;
View Full Code Here

Examples of org.apache.cayenne.query.SQLResultSetMapping

        void convert(List<DataRow> mainRows) {

            List<DataRow> normalized;

            // convert data rows to standardized format...
            SQLResultSetMapping rsMapping = metadata.getResultSetMapping();
            if (rsMapping != null) {
                // expect 1 and only 1 entityMapping...
                EntityResult entityMapping = rsMapping.getEntityResult(0);
                normalized = toNormalizedDataRows(entityMapping, mainRows);
            }
            else {
                normalized = mainRows;
            }
View Full Code Here

Examples of org.apache.cayenne.query.SQLResultSetMapping

    class SingleScalarConversionStrategy extends ObjectConversionStrategy {

        @Override
        void convert(List<DataRow> mainRows) {

            SQLResultSetMapping rsMapping = metadata.getResultSetMapping();

            int rowsLen = mainRows.size();

            List objects = new ArrayList(rowsLen);
            String column = rsMapping.getColumnResult(0);

            // add scalars to the result
            for (DataRow row : mainRows) {
                objects.add(row.get(column));
            }
View Full Code Here

Examples of org.apache.cayenne.query.SQLResultSetMapping

        void convert(List<DataRow> mainRows) {

            int rowsLen = mainRows.size();
            List<Object[]> objects = new ArrayList<Object[]>(rowsLen);

            SQLResultSetMapping rsMapping = metadata.getResultSetMapping();

            // pass 1 - init Object[]'s and resolve scalars for each row

            int resultWidth = rsMapping.getResultDescriptors().size();
            int[] entityPositions = rsMapping.getEntityResultPositions();
            int[] columnPositions = rsMapping.getColumnResultPositions();

            for (DataRow row : mainRows) {
                Object[] resultRow = new Object[resultWidth];
                for (int i = 0; i < columnPositions.length; i++) {
                    int pos = columnPositions[i];
                    resultRow[pos] = row.get(rsMapping.getColumnResult(pos));
                }
                objects.add(resultRow);
            }

            // pass 2 - resolve individual object columns, and then update the rows...
            List[] resultLists = new List[entityPositions.length];
            for (int i = 0; i < entityPositions.length; i++) {
                int pos = entityPositions[i];
                EntityResult entityMapping = rsMapping.getEntityResult(pos);
                List<DataRow> normalized = toNormalizedDataRows(entityMapping, mainRows);

                List<Persistent> nextResult = toObjects(entityMapping
                        .getClassDescriptor(domain.getEntityResolver()), null, normalized);
View Full Code Here

Examples of org.apache.cayenne.query.SQLResultSetMapping

   
    /**
     * @since 3.0
     */
    public SQLResultSetMapping getResultSetMapping(String name) {
        SQLResultSetMapping result = resultSetMappingCache.get(name);

        if (result == null) {
            // reconstruct cache just in case some of the datamaps
            // have changed and now contain the required information
            constructCache();
View Full Code Here

Examples of org.apache.cayenne.query.SQLResultSetMapping

        compiled.setRootId(rootId);
        compiled.setDescriptorsById(descriptorsById);
        compiled.setIncomingById(incomingById);

        if (resultSetMappings != null) {
            SQLResultSetMapping mapping = new SQLResultSetMapping();

            for (int i = 0; i < resultSetMappings.size(); i++) {
                Object nextMapping = resultSetMappings.get(i);
                if (nextMapping instanceof String) {
                    mapping.addColumnResult((String) nextMapping);
                }
                else if (nextMapping instanceof EJBQLExpression) {
                    mapping.addEntityResult(compileEntityResult(
                            (EJBQLExpression) nextMapping,
                            i));
                }
            }
View Full Code Here

Examples of org.apache.cayenne.query.SQLResultSetMapping

    /**
     * Returns a positional column alias, incrementing position index on each call.
     */
    String nextColumnAlias() {

        SQLResultSetMapping resultSetMapping = compiledExpression.getResultSetMapping();
        if (resultSetMapping == null) {
            throw new EJBQLException(
                    "No result set mapping exists for expression, can't map column aliases");
        }

        return resultSetMapping.getColumnResults().get(columnAliasPosition++);
    }
View Full Code Here

Examples of org.apache.cayenne.query.SQLResultSetMapping

        }

        private void addResultSetColumn() {
            if (appendingResultColumns) {
                if (resultSetMapping == null) {
                    resultSetMapping = new SQLResultSetMapping();
                }

                String column = "sc" + resultSetMapping.getColumnResults().size();
                resultSetMapping.addColumnResult(column);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.