Charles Benett wrote:
>
> Hi!
> Using tdk2.1b2 and mysql.
>
> I have a table where I want a foreign key which refers to
> TURBINE_USER.USER_ID.
> Torque seems to generate the right sql but chokes on the om generation
> with:
>
> ERROR!! Attempt to set foreign key to nonexistent table, TURBINE_USER!
> java.lang.NullPointerException
> at
>
>org.apache.turbine.torque.engine.database.transform.XmlToAppData.startElement(XmlToAppData.java:237)
>
> I'm guessing the problem may be that the table definitions are in
> different xml files (project-schema and turbine-schema).
> Has anyone else seen this and what is the work around?
>
> I know mysql doesn't implement foreign keys for referential integrity,
> but it seems useful to indicate the design in the schema.xml and useful
> in case I change db. I'm also guessing that this isn't a mysql specific
> issue.
>
> Thanks,
>
> Charles
>
> the xml is like:
> <table name="IDENTITIES">
> <column name="IDENT_ID" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
> <column name="HANDLE" required="true" size="255" type="VARCHAR"/>
> <column name="USER_ID" required="true" type="INTEGER"/>
>
> <foreign-key foreignTable="TURBINE_USER">
> <reference local="USER_ID" foreign="USER_ID"/>
> </foreign-key>
>
> </table>
>
> the generated sql is like:
> drop table if exists IDENTITIES;
>
> CREATE TABLE IDENTITIES
> (
> IDENT_ID INTEGER NOT NULL AUTO_INCREMENT,
> HANDLE VARCHAR (255) NOT NULL,
> USER_ID INTEGER NOT NULL,
> PRIMARY KEY(IDENT_ID),
> FOREIGN KEY (USER_ID) REFERENCES TURBINE_USER (USER_ID)
> );
>
> CB
>
You have to define a table called TURBINE_USER in the same file you
defined
IDENTITIES. Just don't use *all* the SQL generated, but only the
portions that you are
interested in.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]