Hi,

----- Original Message -----
From: <[EMAIL PROTECTED]>
> I'm just trying to make sure that I understand how foreign key relationships
> should be set up in MapBuilders, so I can determine if the NGMBT is setting
> them up properly.
>
> I have a table created using:
>
> CREATE TABLE TASKMASTER_TASK(
>     TASK_ID        INTEGER      NOT NULL,
>     OWNER_ID       INTEGER      NOT NULL,
>     TASK_NAME      VARCHAR(255) NOT NULL,
>     TASK_DESC      VARCHAR(255) NOT NULL,
>     PARENT_TASK_ID INTEGER,
>     TASK_STATUS    VARCHAR(1),
>     PRIMARY KEY (TASK_ID),
>     FOREIGN KEY (PARENT_TASK_ID)
>     REFERENCES TASKMASTER_TASK(TASK_ID)
> )
> ;
>
> In the resulting TaskMapBuilder.java generated by NGMBT, I see:
>
>         tMap.addForeignKey ( getTask_ParentTaskId(), integer,
>             TaskMapBuilder.getTable(),
>             TaskMapBuilder.getTask_ParentTaskId() );
>
> I'm not sure about the semantics of each of the arguments to the addForeignKey
> method. Should the last two arguments be the table name and column name in
> the table being referenced, or of the table that the foreign key is declared
> in? If the former, then I think the code generated by NGMBT should be:
>
>         tMap.addForeignKey ( getTask_ParentTaskId(), integer,
>             TaskMapBuilder.getTable(),
>             TaskMapBuilder.getTask_TaskId() );
>
> (note the difference to the last line).
>
> -Greg-

I think you're right.  The last two parameters are the foreign table and foreign 
column respectively.  I had a quick look at the
NGMBT code and it looks ok ( although I might be wrong :-).  Another good place to 
look for the bug is MySqlSchemaToDatabaseMap.

~ Leon



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to