Package org.apache.torque

Examples of org.apache.torque.Column


    {
        if (!(possibleColumn instanceof Column))
        {
            return null;
        }
        Column column = (Column) possibleColumn;
        TableMap result = null;
        String tableName = column.getTableName();
        if (tableName == null)
        {
            // try asColumns
            Column asColumn = criteria.getAsColumns().get(
                    column.getSqlExpression());
            if (asColumn != null)
            {
                tableName = asColumn.getTableName();
            }
        }
        if (tableName != null)
        {
            String databaseName = criteria.getDbName();
View Full Code Here


            throws TorqueException
    {
        String tableName = column.getTableName();
        {
            // try asColumns
            Column asColumn = criteria.getAsColumns().get(
                    column.getSqlExpression());
            if (asColumn != null)
            {
                column = asColumn;
                tableName = asColumn.getTableName();
            }
        }

        if (tableName == null)
        {
View Full Code Here

        throws TorqueException
    {
        PreparedStatementPart result = new PreparedStatementPart();
        if (toBuildFrom instanceof Column)
        {
            Column column = (Column) toBuildFrom;
            if (ignoreCase)
            {
                result.getSql().append(
                        adapter.ignoreCase(column.getSqlExpression()));
            }
            else
            {
                result.getSql().append(column.getSqlExpression());
            }
            return result;
        }

        // plain object
View Full Code Here

        UniqueColumnList selectColumns = criteria.getSelectColumns();

        for (Column column : selectColumns)
        {
            String sqlExpression = column.getSqlExpression();
            Column resolvedAlias = criteria.getAsColumns().get(sqlExpression);
            if (resolvedAlias != null)
            {
                // will be handled by processAsColumns
                continue;
            }
View Full Code Here

        UniqueList<String> querySelectClause = query.getSelectClause();
        Map<String, Column> criteriaAsColumns = criteria.getAsColumns();

        for (Map.Entry<String, Column> entry : criteriaAsColumns.entrySet())
        {
            Column column = entry.getValue();
            querySelectClause.add(
                    column.getSqlExpression()
                        + SqlEnum.AS
                        + entry.getKey());
            addTableToFromClause(
                    column,
                    criteria,
View Full Code Here

                org.apache.torque.util.Criteria criteria,
                StringBuilder sb,
                Query query)
            throws TorqueException
    {
        Column column = criterion.getColumn();

        // add the table to the from clause, if it is not already
        // contained there
        // it is important that this piece of code is executed AFTER
        // the joins are processed
        addTableToFromClause(
            column,
            criteria,
            query);

        boolean ignoreCase
                = criteria.isIgnoreCase() || criterion.isIgnoreCase();
        final String dbName = criteria.getDbName();
        final Adapter adapter = Torque.getAdapter(dbName);
        final Database database = Torque.getDatabase(dbName);
        {
            Column databaseColumn = resolveAliasAndAsColumnAndSchema(
                    column,
                    criteria);
            ColumnMap columnMap = null;
            {
                DatabaseMap databaseMap = database.getDatabaseMap();
                TableMap tableMap = databaseMap.getTable(
                        databaseColumn.getTableName());
                if (tableMap != null)
                {
                    columnMap = tableMap.getColumn(
                            databaseColumn.getColumnName());
                }
            }
            if (columnMap != null)
            {
                // do not use ignoreCase on columns
View Full Code Here

        // Check for each String/Character column and apply
        // toUpperCase().
        for (OrderBy orderBy : orderByList)
        {
            Column column = orderBy.getColumn();
            ColumnMap columnMap = MapHelper.getColumnMap(column, crit);
            String sqlExpression = column.getSqlExpression();

            // Either we are not able to look up the column in the
            // databaseMap, then simply use the case in orderBy and
            // hope the user knows what he is
            // doing.
View Full Code Here

        UniqueList<String> selectClause = query.getSelectClause();
        UniqueColumnList groupBy = criteria.getGroupByColumns();

        for (Column groupByColumn : groupBy)
        {
            Column column = criteria.getAsColumns().get(
                    groupByColumn.getSqlExpression());

            if (column == null)
            {
                column = groupByColumn;
            }

            groupByClause.add(column.getSqlExpression());
            selectClause.add(column.getSqlExpression());
            addTableToFromClause(column, criteria, query);
        }
    }
View Full Code Here

        if (!(toAddToFromClause instanceof Column))
        {
            // toAddToFromClause is a literal Value
            return new PreparedStatementPart("?", toAddToFromClause);
        }
        Column column = (Column) toAddToFromClause;
        Column resolvedColumn
                = resolveAliasAndAsColumnAndSchema(column, criteria);
        String fullTableName
                = resolvedColumn.getFullTableName();

        if (!StringUtils.equals(
                resolvedColumn.getTableName(),
                column.getTableName()))
        {
            // If the tables have an alias, add an "<xxx> <yyy> statement"
            // <xxx> AS <yyy> causes problems on oracle
            PreparedStatementPart result = new PreparedStatementPart();
            result.getSql()
                    .append(fullTableName)
                    .append(" ")
                    .append(column.getTableName());
            return result;
        }
        Object resolvedAlias = criteria.getAliases().get(
                resolvedColumn.getTableName());
        if (resolvedAlias != null)
        {
            if (resolvedAlias instanceof Criteria)
            {
                Criteria subquery = (Criteria) resolvedAlias;
                Query renderedSubquery = SqlBuilder.buildQuery(subquery);
                PreparedStatementPart result = new PreparedStatementPart();
                result.getSql().append("(")
                        .append(renderedSubquery.toString())
                        .append(") ")
                        .append(resolvedColumn.getTableName());
                result.getPreparedStatementReplacements().addAll(
                        renderedSubquery.getPreparedStatementReplacements());
                return result;
            }
            else
            {
                throw new TorqueException("Table name "
                    + resolvedColumn.getTableName()
                    + " resolved to an unhandleable class "
                    + resolvedAlias.getClass().getName());
            }
        }
View Full Code Here

        String tableName = null;

        Object lValue = criterion.getLValue();
        if (lValue instanceof Column)
        {
            Column column = (Column) lValue;
            tableName = column.getFullTableName();
        }
        if (tableName == null)
        {
            throw new TorqueException("Could not determine table name "
                    + " as first criterion contains no table name");
View Full Code Here

TOP

Related Classes of org.apache.torque.Column

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.