Examples of TableMap


Examples of org.apache.torque.map.TableMap

     */
    public void doBuild()
            throws Exception
    {
        // Reusable TableMap
        TableMap tMap;

        // Make some objects.
        String string = "";
        Integer integer = new Integer(0);
        java.util.Date date = new Date();

        // Get default map.
        dbMap = Torque.getDatabaseMap();

        // Add tables.
        dbMap.addTable(getTableUser());
        dbMap.addTable(getTableGroup());
        dbMap.addTable(getTableRole());
        dbMap.addTable(getTablePermission());
        dbMap.addTable(getTableUserGroupRole());
        dbMap.addTable(getTableRolePermission());

        // Add User columns.
        tMap = dbMap.getTable(getTableUser());
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        tMap.addPrimaryKey(getUserId(), integer);
        tMap.addColumn(getUsername(), string);
        tMap.addColumn(getPassword(), string);
        tMap.addColumn(getFirstName(), string);
        tMap.addColumn(getLastName(), string);
        tMap.addColumn(getEmail(), string);
        tMap.addColumn(getConfirmValue(), string);
        tMap.addColumn(getCreated(), date);
        tMap.addColumn(getModified(), date);
        tMap.addColumn(getLastLogin(), date);
        tMap.addColumn(getObjectData(), new Hashtable(1));

        // Add Group columns.
        tMap = dbMap.getTable(getTableGroup());
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        tMap.addPrimaryKey(getGroupId(), integer);
        tMap.addColumn(getGroupName(), string);
        tMap.addColumn(getObjectData(), new Hashtable(1));

        // Add Role columns.
        tMap = dbMap.getTable(getTableRole());
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        tMap.addPrimaryKey(getRoleId(), integer);
        tMap.addColumn(getRoleName(), string);
        tMap.addColumn(getObjectData(), new Hashtable(1));

        // Add Permission columns.
        tMap = dbMap.getTable(getTablePermission());
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        tMap.addPrimaryKey(getPermissionId(), integer);
        tMap.addColumn(getPermissionName(), string);
        tMap.addColumn(getObjectData(), new Hashtable(1));

        // Add RolePermission columns.
        tMap = dbMap.getTable(getTableRolePermission());
        tMap.addForeignPrimaryKey(getPermissionId(),
                integer,
                getTablePermission(),
                getPermissionId());
        tMap.addForeignPrimaryKey(getRoleId(),
                integer,
                getTableRole(),
                getRoleId());

        // Add UserGroupRole columns.
        tMap = dbMap.getTable(getTableUserGroupRole());
        tMap.addForeignPrimaryKey(getUserId(),
                integer,
                getTableUser(),
                getUserId());
        tMap.addForeignPrimaryKey(getGroupId(),
                integer,
                getTableGroup(),
                getGroupId());
        tMap.addForeignPrimaryKey(getRoleId(),
                integer,
                getTableRole(),
                getRoleId());
    }
View Full Code Here

Examples of org.apache.torque.map.TableMap

                    + "anything specified to insert");
        }

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

        ColumnMap pk = getPrimaryKey(criteria);

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

Examples of org.apache.torque.map.TableMap

     * @param map the DataBaseMap to setup.
     */
    private final void setupIdTable(DatabaseMap map)
    {
        map.setIdTable("ID_TABLE");
        TableMap tMap = map.getIdTable();
        tMap.addPrimaryKey("ID_TABLE_ID", new Integer(0));
        tMap.addColumn("TABLE_NAME", "");
        tMap.addColumn("NEXT_ID", new Integer(0));
        tMap.addColumn("QUANTITY", new Integer(0));
    }
View Full Code Here

Examples of org.apache.torque.map.TableMap

            throw new TorqueException("Database insert attempted without "
                    + "anything specified to insert");
        }

        DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
        TableMap tableMap = dbMap.getTable(tableName);
        Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
        IdGenerator keyGen = tableMap.getIdGenerator();

        ColumnMap pk = getPrimaryKey(criteria);

        // pk will be null if there is no primary key defined for the table
        // we're inserting into.
View Full Code Here

Examples of org.apache.torque.map.TableMap

     * @param map the DataBaseMap to setup.
     */
    private final void setupIdTable(DatabaseMap map)
    {
        map.setIdTable("ID_TABLE");
        TableMap tMap = map.getIdTable();
        tMap.addPrimaryKey("ID_TABLE_ID", new Integer(0));
        tMap.addColumn("TABLE_NAME", "");
        tMap.addColumn("NEXT_ID", new Integer(0));
        tMap.addColumn("QUANTITY", new Integer(0));
    }
View Full Code Here

Examples of org.apache.torque.map.TableMap

        }

        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

Examples of org.apache.torque.map.TableMap

        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

Examples of org.apache.torque.map.TableMap

     */
    public void doBuild()
            throws Exception
    {
        // Reusable TableMap
        TableMap tMap;

        // Make some objects.
        String string = new String("");
        Integer integer = new Integer(0);
        java.util.Date date = new Date();

        // Get default map.
        dbMap = Torque.getDatabaseMap();

        // Add tables.
        dbMap.addTable(getTableUser());
        dbMap.addTable(getTableGroup());
        dbMap.addTable(getTableRole());
        dbMap.addTable(getTablePermission());
        dbMap.addTable(getTableUserGroupRole());
        dbMap.addTable(getTableRolePermission());

        // Add User columns.
        tMap = dbMap.getTable(getTableUser());
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        tMap.addPrimaryKey(getUserId(), integer);
        tMap.addColumn(getUsername(), string);
        tMap.addColumn(getPassword(), string);
        tMap.addColumn(getFirstName(), string);
        tMap.addColumn(getLastName(), string);
        tMap.addColumn(getEmail(), string);
        tMap.addColumn(getConfirmValue(), string);
        tMap.addColumn(getCreated(), date);
        tMap.addColumn(getModified(), date);
        tMap.addColumn(getLastLogin(), date);
        tMap.addColumn(getObjectData(), new Hashtable(1));

        // Add Group columns.
        tMap = dbMap.getTable(getTableGroup());
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        tMap.addPrimaryKey(getGroupId(), integer);
        tMap.addColumn(getGroupName(), string);
        tMap.addColumn(getObjectData(), new Hashtable(1));

        // Add Role columns.
        tMap = dbMap.getTable(getTableRole());
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        tMap.addPrimaryKey(getRoleId(), integer);
        tMap.addColumn(getRoleName(), string);
        tMap.addColumn(getObjectData(), new Hashtable(1));

        // Add Permission columns.
        tMap = dbMap.getTable(getTablePermission());
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());
        tMap.addPrimaryKey(getPermissionId(), integer);
        tMap.addColumn(getPermissionName(), string);
        tMap.addColumn(getObjectData(), new Hashtable(1));

        // Add RolePermission columns.
        tMap = dbMap.getTable(getTableRolePermission());
        tMap.addForeignPrimaryKey(getPermissionId(),
                integer,
                getTablePermission(),
                getPermissionId());
        tMap.addForeignPrimaryKey(getRoleId(),
                integer,
                getTableRole(),
                getRoleId());

        // Add UserGroupRole columns.
        tMap = dbMap.getTable(getTableUserGroupRole());
        tMap.addForeignPrimaryKey(getUserId(),
                integer,
                getTableUser(),
                getUserId());
        tMap.addForeignPrimaryKey(getGroupId(),
                integer,
                getTableGroup(),
                getGroupId());
        tMap.addForeignPrimaryKey(getRoleId(),
                integer,
                getTableRole(),
                getRoleId());
    }
View Full Code Here

Examples of org.apache.torque.map.TableMap

    public void doBuild() throws TorqueException
    {
        dbMap = Torque.getDatabaseMap("default");

        dbMap.addTable("EMAIL_INBOX");
        TableMap tMap = dbMap.getTable("EMAIL_INBOX");

        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);

        tMap.setPrimaryKeyMethodInfo(tMap.getName());

              tMap.addPrimaryKey("EMAIL_INBOX.EMAIL_INBOX_ID", new Integer(0));
                    tMap.addColumn("EMAIL_INBOX.MESSAGE_ID", new String());
                    tMap.addColumn("EMAIL_INBOX.FILENAME", new String());
                    tMap.addColumn("EMAIL_INBOX.ATTACHMENT", new Object());
                    tMap.addColumn("EMAIL_INBOX.READFLAG", new Integer(0));
          }
View Full Code Here

Examples of org.apache.torque.map.TableMap

    public void doBuild() throws TorqueException
    {
        dbMap = Torque.getDatabaseMap("default");

        dbMap.addTable("COFFEES");
        TableMap tMap = dbMap.getTable("COFFEES");

        tMap.setPrimaryKeyMethod(TableMap.NATIVE);

        tMap.setPrimaryKeyMethodInfo("COFFEES_SEQ");

              tMap.addPrimaryKey("COFFEES.COFFEE_ID", new Integer(0));
                    tMap.addColumn("COFFEES.COFFEE_NAME", new String());
                    tMap.addColumn("COFFEES.SUPPLIER_ID", new Integer(0));
                    tMap.addColumn("COFFEES.PRICE", new Double(0));
                    tMap.addColumn("COFFEES.SALES", new Integer(0));
                    tMap.addColumn("COFFEES.TOTAL", new Integer(0));
          }
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.