Package org.apache.torque.map

Examples of org.apache.torque.map.TableMap


            throws Exception
    {
        // prepare
        DatabaseMap fullyQualifiedDatatabaseMap
            = Torque.getDatabaseMap("fullyQualifiedDatatabaseMap");
        TableMap tableMap = new TableMap(
                "schema.fully_qualified_table",
                fullyQualifiedDatatabaseMap);
        ColumnMap columnMap = new ColumnMap("column", tableMap);
        basePeerImpl.setTableMap(tableMap);
        Criteria criteria = new Criteria();
View Full Code Here


        super.setUp();
        c = new Criteria();
        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

    public void testOrderBy() throws TorqueException
    {
        // 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"));
        c.addAlias("a", "AUTHOR");
View Full Code Here

            throw new TorqueException("No conditions found in Criteria");
        }
        Criteria.Criterion criterion
                = criteria.values().iterator().next();

        TableMap tableMapFromCriteria = MapHelper.getTableMap(
                criterion.getColumn(), criteria, null);
        if (tableMapFromCriteria == null)
        {
            throw new TorqueException("Unqualified column name in criteria"
                    + " or table name not found in database map");
View Full Code Here

                Criteria criteria,
                Criteria.Criterion criterion)
            throws TorqueException
    {
        Column column = criterion.getColumn();
        TableMap tableMapFromCriteria = MapHelper.getTableMap(
                column,
                criteria,
                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(
View Full Code Here

            }
            return;
        }

        Object possibleColumn = criterion.getLValue();
        TableMap tableMapForColumn = MapHelper.getTableMap(
                possibleColumn,
                criteria,
                tableMap);
        // if no description of table available, do not modify anything
        if (tableMapForColumn == null)
        {
            return;
        }
        String columnName = ((Column) possibleColumn).getColumnName();
        ColumnMap columnMap = tableMapForColumn.getColumn(columnName);
        if (columnMap != null)
        {
            if ("BOOLEANINT".equals(columnMap.getTorqueType()))
            {
                replaceBooleanValues(
View Full Code Here

        super.setUp();
        c = new Criteria();
        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

    public void testOrderBy() throws TorqueException
    {
        // 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"));
        c.addAlias("a", "AUTHOR");
View Full Code Here

        }

        String dbName = criteria.getDbName();
        Database database = Torque.getDatabase(dbName);
        DatabaseMap dbMap = database.getDatabaseMap();
        TableMap tableMap = dbMap.getTable(table);
        Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
        IdGenerator keyGen
                = database.getIdGenerator(tableMap.getPrimaryKeyMethod());

        ColumnMap pk = getPrimaryKey(criteria);

        // If the keyMethod is SEQUENCE or IDBROKERTABLE, get the id
        // before the insert.
View Full Code Here

        Iterator keyIt = criteria.keySet().iterator();
        while (keyIt.hasNext())
        {
            String key = (String) keyIt.next();
            String columnName;
            TableMap tableMap = null;
            int dotPosition = key.lastIndexOf(".");
            if (dotPosition == -1)
            {
                columnName = key;
                tableMap = defaultTableMap;
            }
            else
            {
                columnName = key.substring(dotPosition + 1);
                String tableName = key.substring(0, dotPosition);
                String databaseName = criteria.getDbName();
                if (databaseName == null)
                {
                    databaseName = Torque.getDefaultDB();
                }
                DatabaseMap databaseMap = Torque.getDatabaseMap(databaseName);
                if (databaseMap != null)
                {
                    tableMap = databaseMap.getTable(tableName);
                }
                if (tableMap == null)
                {
                    // try aliases
                    Map aliases = criteria.getAliases();
                    if (aliases != null && aliases.get(tableName) != null)
                    {
                        tableName = (String) aliases.get(tableName);
                        tableMap = databaseMap.getTable(tableName);
                    }
                }
                if (tableMap == null)
                {
                    // no description of table available, do not modify anything
                    break;
                }
            }

            ColumnMap columnMap = tableMap.getColumn(columnName);
            if (columnMap != null)
            {
                if ("BOOLEANINT".equals(columnMap.getTorqueType()))
                {
                    Criteria.Criterion criterion = criteria.getCriterion(key);
View Full Code Here

TOP

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

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.