db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amit Rana" <r...@solis.jp>
Subject class cast exception while inserting
Date Tue, 21 Oct 2003 01:07:47 GMT

	I am having problems with inserting a new record in table with
following definition.
<table name="SC_COMMON_ORDERS">
	<column name="id" required="true" primaryKey="true"
autoIncrement="true" type="INTEGER"/>
	<column name="line_number" required="true" primaryKey="true"
default="1" type="INTEGER"/>
	---other columns

	I get a ClassCastException

	Any advice on how I can solve it?

I traced the code and the problem is that
BaseScCommonOrdersPeer.doInsert is returning 1 key although it should be
returning an array of keys.
I am using "native" for idbroker so after inserting BasePeer returns
primary key value from the table, In our case we have a composite key so
it should be returning an array not a single value.
Any ideas? Am I doing something wrong?

public void setPrimaryKey(ObjectKey key) throws TorqueException
	SimpleKey[] keys = (SimpleKey[]) key.getValue(); --throws
exception line 240
	SimpleKey tmpKey = null;
Base..Peer's method
public static void doInsert(ScCommonOrders obj, Connection con)
        throws TorqueException
        obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); -- line

     * Method to perform inserts based on values and keys in a
     * Criteria.
     * <p>
     * If the primary key is auto incremented the data in Criteria
     * will be inserted and the auto increment value will be returned.
     * <p>
     * If the primary key is included in Criteria then that value will
     * be used to insert the row.
     * <p>
     * If no primary key is included in Criteria then we will try to
     * figure out the primary key from the database map and insert the
     * row with the next available id using util.db.IDBroker.
     * <p>
     * If no primary key is defined for the table the values will be
     * inserted as specified in Criteria and -1 will be returned.
     * @param criteria Object containing values to insert.
     * @return An Object which is the id of the row that was inserted
     * (if the table has a primary key) or null (if the table does not
     * have a primary key).
     * @throws TorqueException Any exceptions caught during processing
will be
     *         rethrown wrapped into a TorqueException.
    public static ObjectKey doInsert(Criteria criteria) throws

To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message