Package org.apache.cayenne.access.jdbc

Examples of org.apache.cayenne.access.jdbc.ColumnDescriptor


            if (attribute == null) {
                throw new CayenneRuntimeException("Attribute does not exist: "
                        + customAttributes.get(i));
            }

            columns.add(new ColumnDescriptor(attribute, getCurrentAlias()));
        }

        return columns;
    }
View Full Code Here


            Set<DbAttribute> skipSet,
            String label) {

        if (skipSet.add(attribute)) {
            String alias = getCurrentAlias();
            ColumnDescriptor column = (objAttribute != null) ? new ColumnDescriptor(
                    objAttribute,
                    attribute,
                    alias) : new ColumnDescriptor(attribute, alias);

            if (label != null) {
                column.setDataRowKey(label);
            }

            columns.add(column);

            // TODO: andrus, 5/7/2006 - replace 'columns' collection with this map, as it
            // is redundant
            defaultAttributesByColumn.put(column, objAttribute);
        }
        else if (objAttribute != null) {

            // record ObjAttribute override
            for (ColumnDescriptor column : columns) {
                if (attribute.getName().equals(column.getName())) {

                    // kick out the original attribute
                    ObjAttribute original = defaultAttributesByColumn.remove(column);

                    if (original != null) {
                        if (attributeOverrides == null) {
                            attributeOverrides = new HashMap<ObjAttribute, ColumnDescriptor>();
                        }

                        attributeOverrides.put(original, column);
                        column.setJavaClass(Void.TYPE.getName());
                    }

                    break;
                }
            }
View Full Code Here

            else {
                if (result == null) {
                    result = new DataRow(2);
                }

                ColumnDescriptor descriptor = new ColumnDescriptor(parameter);
                ExtendedType type = getAdapter().getExtendedTypes().getRegisteredType(
                        descriptor.getJavaClass());
                Object val = type.materializeObject(statement, i + 1, descriptor
                        .getJdbcType());

                result.put(descriptor.getLabel(), val);
            }
        }

        if (result != null && !result.isEmpty()) {
            // treat out parameters as a separate data row set
View Full Code Here

                throw new CayenneRuntimeException("Attribute does not exist: "
                        + customAttributes.get(i));
            }

            String alias = aliasForTable((DbEntity) attribute.getEntity());
            columns.add(new ColumnDescriptor(attribute, alias));
        }

        return columns;
    }
View Full Code Here

            Set skipSet,
            String label) {

        if (skipSet.add(attribute)) {
            String alias = aliasForTable((DbEntity) attribute.getEntity());
            ColumnDescriptor column = (objAttribute != null) ? new ColumnDescriptor(
                    objAttribute,
                    attribute,
                    alias) : new ColumnDescriptor(attribute, alias);

            if (label != null) {
                column.setLabel(label);
            }

            columns.add(column);

            // TODO: andrus, 5/7/2006 - replace 'columns' collection with this map, as it
            // is redundant
            defaultAttributesByColumn.put(column, objAttribute);
        }
        else if (objAttribute != null) {

            // record ObjAttribute override
            for (ColumnDescriptor column : columns) {
                if (attribute.getName().equals(column.getName())) {

                    // kick out the original attribute
                    ObjAttribute original = (ObjAttribute) defaultAttributesByColumn
                            .remove(column);

                    if (original != null) {
                        if (attributeOverrides == null) {
                            attributeOverrides = new HashMap();
                        }

                        attributeOverrides.put(original, column);
                        column.setJavaClass(Void.TYPE.getName());
                    }

                    break;
                }
            }
View Full Code Here

        this.columns = new ColumnDescriptor[size];
        targetSource.values().toArray(columns);
    }

    private ColumnDescriptor appendColumn(Map map, String name, String label) {
        ColumnDescriptor column = (ColumnDescriptor) map.get(name);

        if (column == null) {
            column = new ColumnDescriptor();
            column.setName(name);
            column.setLabel(label);
            map.put(name, column);
        }

        return column;
    }
View Full Code Here

            String label) {

        String alias = getCurrentAlias();
        if (skipSet.add(new ColumnTracker(alias, attribute))) {

            ColumnDescriptor column = (objAttribute != null) ? new ColumnDescriptor(
                    objAttribute,
                    attribute,
                    alias) : new ColumnDescriptor(attribute, alias);

            if (label != null) {
                column.setDataRowKey(label);
            }

            columns.add(column);

            // TODO: andrus, 5/7/2006 - replace 'columns' collection with this map, as it
            // is redundant
            defaultAttributesByColumn.put(column, objAttribute);
        }
        else if (objAttribute != null) {

            // record ObjAttribute override
            for (ColumnDescriptor column : columns) {
                if (attribute.getName().equals(column.getName())) {

                    // kick out the original attribute
                    ObjAttribute original = defaultAttributesByColumn.remove(column);

                    if (original != null) {
                        if (attributeOverrides == null) {
                            attributeOverrides = new HashMap<ObjAttribute, ColumnDescriptor>();
                        }

                        attributeOverrides.put(original, column);
                        column.setJavaClass(Void.TYPE.getName());
                    }

                    break;
                }
            }
View Full Code Here

        // TESTING THIS ***
        // A.ARTIST_ID, A.DATE_OF_BIRTH, A.ARTIST_NAME
        ColumnDescriptor[] columns = new ColumnDescriptor[3];

        // read ID as Long, and everything else as default types
        columns[0] = new ColumnDescriptor("ARTIST_ID", Types.BIGINT, Long.class
                .getName());
        columns[1] = new ColumnDescriptor("ARTIST_NAME", Types.CHAR, String.class
                .getName());
        columns[2] = new ColumnDescriptor("DATE_OF_BIRTH", Types.DATE, Date.class
                .getName());
        q.addResultDescriptor(columns);

        List rows = runProcedureSelect(q);

View Full Code Here

        this.columns = new ColumnDescriptor[size];
        targetSource.values().toArray(columns);
    }

    private ColumnDescriptor appendColumn(Map map, String name, String label) {
        ColumnDescriptor column = (ColumnDescriptor) map.get(name);

        if (column == null) {
            column = new ColumnDescriptor();
            column.setName(name);
            column.setLabel(label);
            map.put(name, column);
        }

        return column;
    }
View Full Code Here

        if (forcingDistinct || getSelectQuery().isDistinct()) {

            suppressingDistinct = false;
            Iterator it = resultColumns.iterator();
            while (it.hasNext()) {
                ColumnDescriptor column = (ColumnDescriptor) it.next();
                if (isUnsupportedForDistinct(column.getJdbcType())) {
                    suppressingDistinct = true;
                    break;
                }
            }

            if (!suppressingDistinct) {
                queryBuf.append("DISTINCT ");
            }
        }

        // convert ColumnDescriptors to column names
        List selectColumnExpList = new ArrayList();

        Iterator it = resultColumns.iterator();
        while (it.hasNext()) {
            ColumnDescriptor column = (ColumnDescriptor) it.next();
            selectColumnExpList.add(column.getQualifiedColumnName());
        }

        // append any column expressions used in the order by if this query
        // uses the DISTINCT modifier
        if (forcingDistinct || getSelectQuery().isDistinct()) {
View Full Code Here

TOP

Related Classes of org.apache.cayenne.access.jdbc.ColumnDescriptor

Copyright © 2018 www.massapicom. 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.