Package org.apache.torque.map

Examples of org.apache.torque.map.ColumnMap


                getTableMap().getPrimaryKeyMethod());

        SimpleKey id = null;
        // can currently generate only single column pks, therefore a single
        // columnMap is ok
        ColumnMap primaryKey = null;
        if (keyGen != null)
        {
            // fail on multiple pks
            primaryKey = getTableMap().getPrimaryKey();
View Full Code Here


    public int doUpdate(
                ColumnValues updateValues,
                Connection connection)
            throws TorqueException
    {
        ColumnMap pk = getTableMap().getPrimaryKey();
        org.apache.torque.criteria.Criteria selectCriteria = null;

        if (pk != null && updateValues.containsKey(pk.getSqlExpression()))
        {
            selectCriteria = new org.apache.torque.criteria.Criteria();
            selectCriteria.where(pk,
                updateValues.remove(pk.getSqlExpression()));
        }
        else
        {
            throw new TorqueException("No PK specified for database update");
        }
View Full Code Here

                tableMap);
        // if no description of table available, do not modify anything
        if (tableMapFromCriteria != null)
        {
            String columnName = column.getColumnName();
            ColumnMap columnMap = tableMapFromCriteria.getColumn(columnName);
            if (columnMap != null)
            {
                if ("BOOLEANINT".equals(columnMap.getTorqueType()))
                {
                    replaceBooleanValues(
                            criterion,
                            Integer.valueOf(1),
                            Integer.valueOf(0));
                }
                else if ("BOOLEANCHAR".equals(columnMap.getTorqueType()))
                {
                    replaceBooleanValues(criterion, "Y", "N");
                 }
            }
        }
View Full Code Here

        if (tableMapForColumn == null)
        {
            return;
        }
        String columnName = ((Column) possibleColumn).getColumnName();
        ColumnMap columnMap = tableMapForColumn.getColumn(columnName);
        if (columnMap != null)
        {
            if ("BOOLEANINT".equals(columnMap.getTorqueType()))
            {
                replaceBooleanValues(
                        criterion,
                        Integer.valueOf(1),
                        Integer.valueOf(0));
            }
            else if ("BOOLEANCHAR".equals(columnMap.getTorqueType()))
            {
                replaceBooleanValues(criterion, "Y", "N");
             }
        }
    }
View Full Code Here

        throws TorqueException
    {
        for (Map.Entry<Column, JdbcTypedValue> entry : columnValues.entrySet())
        {
            String columnName = entry.getKey().getColumnName();
            ColumnMap column = getTableMap().getColumn(columnName);
            if (column != null)
            {
                JdbcTypedValue columnValue = entry.getValue();
                if ("BOOLEANINT".equals(column.getTorqueType()))
                {
                    if (Boolean.TRUE.equals(columnValue.getValue()))
                    {
                        entry.setValue(new JdbcTypedValue(1, Types.INTEGER));
                    }
                    else if (Boolean.FALSE.equals(columnValue.getValue()))
                    {
                        entry.setValue(new JdbcTypedValue(0, Types.INTEGER));
                    }
                    else if (columnValue.getValue() == null)
                    {
                        entry.setValue(new JdbcTypedValue(null, Types.INTEGER));
                    }
                }
                else if ("BOOLEANCHAR".equals(column.getTorqueType()))
                {
                    if (Boolean.TRUE.equals(columnValue.getValue()))
                    {
                        entry.setValue(new JdbcTypedValue("Y", Types.CHAR));
                    }
View Full Code Here

        DatabaseMap databaseMap = Torque.getDatabaseMap("postgresql");
        if (!databaseMap.containsTable("TABLE"))
        {
            TableMap tableMap = databaseMap.addTable("TABLE");
            {
                ColumnMap columnMap1 = new ColumnMap("COLUMN1", tableMap);
                columnMap1.setType(new String(""));
                columnMap1.setJavaType("String");
                tableMap.addColumn(columnMap1);
            }
            {
                ColumnMap columnMap2 = new ColumnMap("COLUMN2", tableMap);
                columnMap2.setType(new String(""));
                columnMap2.setJavaType("String");
                tableMap.addColumn(columnMap2);
            }
            {
                ColumnMap columnMap3 = new ColumnMap("COLUMN3", tableMap);
                columnMap3.setType(new String(""));
                columnMap3.setJavaType("String");
                tableMap.addColumn(columnMap3);
            }
            {
                ColumnMap columnMap4 = new ColumnMap("COLUMN4", tableMap);
                columnMap4.setType(new Integer(0));
                columnMap4.setJavaType("Integer");
                tableMap.addColumn(columnMap4);
            }
        }
    }
View Full Code Here

        // we need a rudimentary databaseMap for this test case to work
        DatabaseMap dbMap = Torque.getDatabaseMap(Torque.getDefaultDB());

        TableMap tableMap = dbMap.addTable("AUTHOR");

        ColumnMap columnMap = new ColumnMap("NAME", tableMap);
        columnMap.setType("");
        tableMap.addColumn(columnMap);

        columnMap = new ColumnMap("AUTHOR_ID", tableMap);
        columnMap.setType(new Integer(0));
        tableMap.addColumn(columnMap);

        // check that alias'ed tables are referenced by their alias
        // name when added to the select clause.
        c.addSelectColumn(new ColumnImpl("AUTHOR", "NAME"));
View Full Code Here

        ColumnMap[] columnMaps = dbMap.getTable(table).getColumns();
        boolean shouldSave = false;
        for (int j = 0; j < columnMaps.length; j++)
        {
            ColumnMap colMap = columnMaps[j];
            String colName = colMap.getColumnName();
            String key = new StringBuffer(colMap.getTableName())
                    .append('.')
                    .append(colName)
                    .toString();
            if (criteria.containsKey(key))
            {
View Full Code Here

    {
        // Assume all the keys are for the same table.
        String key = (String) criteria.keys().nextElement();

        String table = criteria.getTableName(key);
        ColumnMap pk = null;

        if (!table.equals(""))
        {
            DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
            if (dbMap == null)
View Full Code Here

     *         rethrown wrapped into a TorqueException.
     */
    public static void doUpdate(Criteria updateValues, Connection con)
        throws TorqueException
    {
        ColumnMap pk = getPrimaryKey(updateValues);
        Criteria selectCriteria = null;

        if (pk != null && updateValues.containsKey(pk.getFullyQualifiedName()))
        {
            selectCriteria = new Criteria(2);
            selectCriteria.put(pk.getFullyQualifiedName(),
                updateValues.remove(pk.getFullyQualifiedName()));
        }
        else
        {
            throw new TorqueException("No PK specified for database update");
        }
View Full Code Here

TOP

Related Classes of org.apache.torque.map.ColumnMap

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.