db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Riza Nugraha <rnugr...@gmail.com>
Subject Make Foreign Key as Primary Key
Date Sat, 16 Jul 2005 08:40:31 GMT
Hi,
Is it possible to make a foreign key as primary key in torque? Because
I had following SQLException when inserting records.

--------------
java.sql.SQLException: Duplicate key or integrity constraint violation
message from server: "
Cannot add or update a child row: a foreign key constraint fails"
--------------

Here's the schema and I'm using MySQL 4.1:

--------------
    <table name="vehicle" description="vehicle's info" idMethod="native">
        <column name="id" primaryKey="true" required="true"
autoIncrement="true" type="INTEGER"/>
        <column name="owner_id" primaryKey="true" required="true"
type="INTEGER"/>
        <column name="name" type="VARCHAR"/>
        <foreign-key foreignTable="owner">
            <reference foreign="id" local="owner_id"/>
        </foreign-key>
    </table>

    <table name="owner" description="owner's info" idMethod="native">
         <column name="id" primaryKey="true" required="true"
autoIncrement="true" type="INTEGER"/>
        <column name="name" type="VARCHAR"/>
    </table>
--------------



Thank you,


Riza Nugraha
=====================
Email : rnugraha@gmail.com
Website : http://rnugraha.net

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


Mime
View raw message