Package org.apache.torque.map

Examples of org.apache.torque.map.ColumnMap


        tMap.setOMClass( org.apache.turbine.services.security.torque.om.TurbineGroup.class );
        tMap.setPeerClass( org.apache.turbine.services.security.torque.om.TurbineGroupPeer.class );
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());

        ColumnMap cMap = null;


  // ------------- Column: GROUP_ID --------------------
        cMap = new ColumnMap( "GROUP_ID", tMap);
        cMap.setType( new Integer(0) );
        cMap.setTorqueType( "INTEGER" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(true);
        cMap.setNotNull(true);
        cMap.setJavaName( "GroupId" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setInheritance("false");
        cMap.setPosition(1);
        tMap.addColumn(cMap);
  // ------------- Column: GROUP_NAME --------------------
        cMap = new ColumnMap( "GROUP_NAME", tMap);
        cMap.setType( "" );
        cMap.setTorqueType( "VARCHAR" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(true);
        cMap.setJavaName( "Name" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setInheritance("false");
        cMap.setSize( 64 );
        cMap.setPosition(2);
        tMap.addColumn(cMap);
        tMap.setUseInheritance(false);
    }
View Full Code Here


        tMap.setOMClass( org.apache.turbine.services.security.torque.om.TurbinePermission.class );
        tMap.setPeerClass( org.apache.turbine.services.security.torque.om.TurbinePermissionPeer.class );
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());

        ColumnMap cMap = null;


  // ------------- Column: PERMISSION_ID --------------------
        cMap = new ColumnMap( "PERMISSION_ID", tMap);
        cMap.setType( new Integer(0) );
        cMap.setTorqueType( "INTEGER" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(true);
        cMap.setNotNull(true);
        cMap.setJavaName( "PermissionId" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setInheritance("false");
        cMap.setPosition(1);
        tMap.addColumn(cMap);
  // ------------- Column: PERMISSION_NAME --------------------
        cMap = new ColumnMap( "PERMISSION_NAME", tMap);
        cMap.setType( "" );
        cMap.setTorqueType( "VARCHAR" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(true);
        cMap.setJavaName( "Name" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setInheritance("false");
        cMap.setSize( 64 );
        cMap.setPosition(2);
        tMap.addColumn(cMap);
        tMap.setUseInheritance(false);
    }
View Full Code Here

        tMap.setOMClass( org.apache.turbine.services.schedule.JobEntry.class );
        tMap.setPeerClass( org.apache.turbine.services.schedule.JobEntryPeer.class );
        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
        tMap.setPrimaryKeyMethodInfo(tMap.getName());

        ColumnMap cMap = null;


  // ------------- Column: JOB_ID --------------------
        cMap = new ColumnMap( "JOB_ID", tMap);
        cMap.setType( new Integer(0) );
        cMap.setTorqueType( "INTEGER" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(true);
        cMap.setNotNull(true);
        cMap.setJavaName( "JobId" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setInheritance("false");
        cMap.setPosition(1);
        tMap.addColumn(cMap);
  // ------------- Column: SECOND --------------------
        cMap = new ColumnMap( "SECOND", tMap);
        cMap.setType( new Integer(0) );
        cMap.setTorqueType( "INTEGER" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(true);
        cMap.setJavaName( "Second" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setDefault("-1");
        cMap.setInheritance("false");
        cMap.setPosition(2);
        tMap.addColumn(cMap);
  // ------------- Column: MINUTE --------------------
        cMap = new ColumnMap( "MINUTE", tMap);
        cMap.setType( new Integer(0) );
        cMap.setTorqueType( "INTEGER" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(true);
        cMap.setJavaName( "Minute" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setDefault("-1");
        cMap.setInheritance("false");
        cMap.setPosition(3);
        tMap.addColumn(cMap);
  // ------------- Column: HOUR --------------------
        cMap = new ColumnMap( "HOUR", tMap);
        cMap.setType( new Integer(0) );
        cMap.setTorqueType( "INTEGER" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(true);
        cMap.setJavaName( "Hour" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setDefault("-1");
        cMap.setInheritance("false");
        cMap.setPosition(4);
        tMap.addColumn(cMap);
  // ------------- Column: WEEK_DAY --------------------
        cMap = new ColumnMap( "WEEK_DAY", tMap);
        cMap.setType( new Integer(0) );
        cMap.setTorqueType( "INTEGER" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(true);
        cMap.setJavaName( "WeekDay" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setDefault("-1");
        cMap.setInheritance("false");
        cMap.setPosition(5);
        tMap.addColumn(cMap);
  // ------------- Column: DAY_OF_MONTH --------------------
        cMap = new ColumnMap( "DAY_OF_MONTH", tMap);
        cMap.setType( new Integer(0) );
        cMap.setTorqueType( "INTEGER" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(true);
        cMap.setJavaName( "DayOfMonth" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setDefault("-1");
        cMap.setInheritance("false");
        cMap.setPosition(6);
        tMap.addColumn(cMap);
  // ------------- Column: TASK --------------------
        cMap = new ColumnMap( "TASK", tMap);
        cMap.setType( "" );
        cMap.setTorqueType( "VARCHAR" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(true);
        cMap.setJavaName( "Task" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setInheritance("false");
        cMap.setSize( 99 );
        cMap.setPosition(7);
        tMap.addColumn(cMap);
  // ------------- Column: EMAIL --------------------
        cMap = new ColumnMap( "EMAIL", tMap);
        cMap.setType( "" );
        cMap.setTorqueType( "VARCHAR" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(false);
        cMap.setJavaName( "Email" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setInheritance("false");
        cMap.setSize( 99 );
        cMap.setPosition(8);
        tMap.addColumn(cMap);
  // ------------- Column: PROPERTY --------------------
        cMap = new ColumnMap( "PROPERTY", tMap);
        cMap.setType( new Object() );
        cMap.setTorqueType( "VARBINARY" );
        cMap.setUsePrimitive(true);
        cMap.setPrimaryKey(false);
        cMap.setNotNull(false);
        cMap.setJavaName( "Property" );
        cMap.setAutoIncrement(false);
        cMap.setProtected(false);
        cMap.setInheritance("false");
        cMap.setPosition(9);
        tMap.addColumn(cMap);
        tMap.setUseInheritance(false);
    }
View Full Code Here

            HashSet whereClause = new HashSet();

            ColumnMap[] columnMaps = dbMap.getTable(tab).getColumns();
            for (int j = 0; j < columnMaps.length; j++)
            {
                ColumnMap colMap = columnMaps[j];
                if (colMap.isPrimaryKey())
                {
                    kd.addAttrib(colMap.getColumnName());
                }
                String key = new StringBuffer(colMap.getTableName())
                        .append('.')
                        .append(colMap.getColumnName())
                        .toString();
                if (criteria.containsKey(key))
                {
                    if (criteria.getComparison(key).equals(Criteria.CUSTOM))
                    {
                        whereClause.add(criteria.getString(key));
                    }
                    else
                    {
                        whereClause.add(SqlExpression.build(
                                colMap.getColumnName(),
                                criteria.getValue(key),
                                criteria.getComparison(key),
                                criteria.isIgnoreCase(),
                                db));
                    }
View Full Code Here

        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.
        if (pk != null && !criteria.containsKey(pk.getFullyQualifiedName()))
        {
            if (keyGen == null)
            {
                throw new TorqueException(
                    "IdGenerator for table '" + tableName + "' is null");
            }
            // If the keyMethod is SEQUENCE or IDBROKERTABLE, get the id
            // before the insert.

            if (keyGen.isPriorToInsert())
            {
                try
                {
                    if (pk.getType() instanceof Number)
                    {
                        id = new NumberKey(
                                keyGen.getIdAsBigDecimal(con, keyInfo));
                    }
                    else
                    {
                        id = new StringKey(keyGen.getIdAsString(con, keyInfo));
                    }
                }
                catch (Exception e)
                {
                    throwTorqueException(e);
                }
                criteria.add(pk.getFullyQualifiedName(), id);
            }
        }

        // Use Village to perform the insert.
        TableDataSet tds = null;
        try
        {
            tds = new TableDataSet(con, tableName);
            Record rec = tds.addRecord();
            BasePeer.insertOrUpdateRecord(rec, tableName, criteria);
        }
        catch (Exception e)
        {
            throwTorqueException(e);
        }
        finally
        {
            if (tds != null)
            {
                try
                {
                    tds.close();
                }
                catch (Exception e)
                {
                    throwTorqueException(e);
                }
            }
        }

        // If the primary key column is auto-incremented, get the id
        // now.
        if (pk != null && keyGen != null && keyGen.isPostInsert())
        {
            try
            {
                if (pk.getType() instanceof Number)
                {
                    id = new NumberKey(keyGen.getIdAsBigDecimal(con, keyInfo));
                }
                else
                {
View Full Code Here

        ColumnMap[] columnMaps = dbMap.getTable(tableName).getColumns();
        boolean shouldSave = false;
        for (int j = 0; j < columnMaps.length; j++)
        {
            ColumnMap colMap = columnMaps[j];
            String key = new StringBuffer(colMap.getTableName())
                    .append('.')
                    .append(colMap.getColumnName())
                    .toString();
            if (criteria.containsKey(key))
            {
                // A village Record.setValue( String, Object ) would
                // be nice here.
                Object obj = criteria.getValue(key);
                if (obj instanceof SimpleKey)
                {
                    obj = ((SimpleKey) obj).getValue();
                }
                try
                {
                    if (obj == null)
                    {
                        rec.setValueNull(colMap.getColumnName());
                    }
                    else if (obj instanceof String)
                    {
                        rec.setValue(colMap.getColumnName(), (String) obj);
                    }
                    else if (obj instanceof Integer)
                    {
                        rec.setValue(colMap.getColumnName(),
                                criteria.getInt(key));
                    }
                    else if (obj instanceof BigDecimal)
                    {
                        rec.setValue(colMap.getColumnName(), (BigDecimal) obj);
                    }
                    else if (obj instanceof Boolean)
                    {
                        rec.setValue(colMap.getColumnName(),
                            criteria.getBoolean(key) ? 1 : 0);
                    }
                    else if (obj instanceof java.util.Date)
                    {
                        rec.setValue(colMap.getColumnName(),
                            (java.util.Date) obj);
                    }
                    else if (obj instanceof Float)
                    {
                        rec.setValue(colMap.getColumnName(),
                            criteria.getFloat(key));
                    }
                    else if (obj instanceof Double)
                    {
                        rec.setValue(colMap.getColumnName(),
                            criteria.getDouble(key));
                    }
                    else if (obj instanceof Byte)
                    {
                        rec.setValue(colMap.getColumnName(),
                            ((Byte) obj).byteValue());
                    }
                    else if (obj instanceof Long)
                    {
                        rec.setValue(colMap.getColumnName(),
                            criteria.getLong(key));
                    }
                    else if (obj instanceof Short)
                    {
                        rec.setValue(colMap.getColumnName(),
                            ((Short) obj).shortValue());
                    }
                    else if (obj instanceof Hashtable)
                    {
                        rec.setValue(colMap.getColumnName(),
                            hashtableToByteArray((Hashtable) obj));
                    }
                    else if (obj instanceof byte[])
                    {
                        rec.setValue(colMap.getColumnName(), (byte[]) obj);
                    }
                }
                catch (Exception e)
                {
                    throwTorqueException(e);
View Full Code Here

                else
                {
                    columnName = orderByColumn.substring(
                            orderByColumn.indexOf('.') + 1, spacePos);
                }
                ColumnMap column = dbMap.getTable(table).getColumn(columnName);
                if (column.getType() instanceof String)
                {
                    if (spacePos == -1)
                    {
                        orderByClause.add(
                                db.ignoreCaseInOrderBy(orderByColumn));
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

            DatabaseMap tempDbMap = dbMap;

            ColumnMap[] columnMaps = tempDbMap.getTable(tab).getColumns();
            for (int j = 0; j < columnMaps.length; j++)
            {
                ColumnMap colMap = columnMaps[j];
                if (colMap.isPrimaryKey())
                {
                    kd.addAttrib(colMap.getColumnName());
                }
                String key = new StringBuffer(colMap.getTableName())
                        .append('.')
                        .append(colMap.getColumnName())
                        .toString();
                if (selectCriteria.containsKey(key))
                {
                    if (selectCriteria
                        .getComparison(key)
                        .equals(Criteria.CUSTOM))
                    {
                        whereClause.add(selectCriteria.getString(key));
                    }
                    else
                    {
                        whereClause.add(
                            SqlExpression.build(
                                colMap.getColumnName(),
                                selectCriteria.getValue(key),
                                selectCriteria.getComparison(key),
                                selectCriteria.isIgnoreCase(),
                                db));
                    }
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.