You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "Weaver, Scott" <Sw...@rippe.com> on 2001/12/10 20:42:51 UTC

Torque is generating incorrect code, .set${colFK.JavaName}

Turbine: 2.2b1(CVS HEAD from a month ago and CVS HEAD from to today)
Torque: 1.0 and 3.0-dev(HEAD from CVS today)

Has anyone ever seen Torque do this when generating a base object class:

setId(StringKey v) throws Exception
{

// update associated Resource
if (collResources != null )
   {
       for (int i=0; i<collResources.size(); i++)
       {
           ((Resource)collResources.get(i))
            .set${colFK.JavaName}(v);
        }
   }

...(more code)
}
instead generating the correct method name, it just puts in
".set${colFK.JavaName}"  which means colFK.JavaName is returning null.

This only happens on with certain base objects that are tied to central
Resource file by a foreign key.
Example:

<table name="RESOURCE" idMethod="idBroker>
    <column name="RESOURCE_ID" javaName="Id" primaryKey="true"
required="true" type="VARCHAR" size="100"/>
    <!--Remote Object ID for this resource-->
    <column name="REMOTE_ID" javaName="RemoteId" required="true"
type="VARCHAR" size="100"/>
    <column name="RESOURCE_TYPE" javaName="Type" required="true"
type="VARCHAR" size="100"/>
    <column name="RESOURCE_TEXT" javaName="Text" required="false"
type="LONGVARCHAR"/>

    <foreign-key foreignTable="TABLE01">
        <reference local="REMOTE_ID" foreign="TABLE01_ID"/>
    </foreign-key>
    <foreign-key foreignTable="TABLE02">
        <reference local="REMOTE_ID" foreign="TABLE02_ID"/>
    </foreign-key>
    <foreign-key foreignTable="TABLE03">
        <reference local="REMOTE_ID" foreign="TABLE03_ID"/>
    </foreign-key>
    <foreign-key foreignTable="TABLE04">
        <reference local="REMOTE_ID" foreign="TABLE04_ID"/>
    </foreign-key>
    <foreign-key foreignTable="TABLE05">
        <reference local="REMOTE_ID" foreign="TABLE05_ID"/>
    </foreign-key>
    ...(lots of FK mappings)
    <foreign-key foreignTable="TABLEn">
        <reference local="REMOTE_ID" foreign="TABLEn_ID"/>
    </foreign-key>
</table>


<!--Some Table examples -->
<table name="TABLE01" idMethod="idBroker>
   <column name="TABLE01_ID" javaName="Id" primaryKey="true" required="true"
type="VARCHAR" size="100"/>
   ...(other stuff)
</table>

<table name="TABLE02" idMethod="idBroker>
   <column name="TABLE02_ID" javaName="Id" primaryKey="true" required="true"
type="VARCHAR" size="100"/>
   ...(other stuff)
</table>


<table name="TABLE0n" idMethod="idBroker>
   <column name="TABLE0n_ID" javaName="Id" primaryKey="true" required="true"
type="VARCHAR" size="100"/>
   ...(other stuff)
</table>




All my base objects will have unique ID's generated by a modified version of
IDBroker, and that's what I use to tie my important tables to any number of
miscellaneous Resources via the REMOTE_ID column.  However, for some reason,
some of the base objects exhibit the behavior stated above when ant
project-om is run.  

Here is what is even more strange.  Let's say TABLE05 is failing as
documented above when generating the om.  Now If I were to switch places
with TABLE01 in the xml schema, the om for TABLE05 generates fine, and even
more surprising is that TABLE01 also generates fine also.  Unfortunately,
this approach does not always fix the problem and sometimes causes other
objects to generate failing source code that where previously fine.

Any clues?

p.s.

I have tried adding debugging statements to Object.vm, and have found that
$fk.ForeignLocalMapping.get($col.Name) is returning (in the failing code) a
null value meaning that (I think) the Hashtable in ForeignKey that
represents the foreignColumns is not being fully/correctly  populated for
some reason. 

Scott



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque is generating incorrect code, .set${colFK.JavaName}

Posted by Kelvin Tan <ke...@relevanz.com>.
Yep. I got this a while back. The problem is multiple foreign keys of the
same column...:)

Trouble is that this isn't enforced in the DTD. However, some might say its
a feature instead of a bug, since I was told to re-examine my database
schema if I ever needed to have multiple foreign keys to the same column...

What I was trying to do at that point was basically map inheritance to the
database, which of course, is plain impractical.

Kelvin

----- Original Message -----
From: Weaver, Scott <Sw...@rippe.com>
To: Turbine Users List <tu...@jakarta.apache.org>
Sent: Tuesday, December 11, 2001 3:42 AM
Subject: Torque is generating incorrect code, .set${colFK.JavaName}


> Turbine: 2.2b1(CVS HEAD from a month ago and CVS HEAD from to today)
> Torque: 1.0 and 3.0-dev(HEAD from CVS today)
>
> Has anyone ever seen Torque do this when generating a base object class:
>
> setId(StringKey v) throws Exception
> {
>
> // update associated Resource
> if (collResources != null )
>    {
>        for (int i=0; i<collResources.size(); i++)
>        {
>            ((Resource)collResources.get(i))
>             .set${colFK.JavaName}(v);
>         }
>    }
>
> ...(more code)
> }
> instead generating the correct method name, it just puts in
> ".set${colFK.JavaName}"  which means colFK.JavaName is returning null.
>
> This only happens on with certain base objects that are tied to central
> Resource file by a foreign key.
> Example:
>
> <table name="RESOURCE" idMethod="idBroker>
>     <column name="RESOURCE_ID" javaName="Id" primaryKey="true"
> required="true" type="VARCHAR" size="100"/>
>     <!--Remote Object ID for this resource-->
>     <column name="REMOTE_ID" javaName="RemoteId" required="true"
> type="VARCHAR" size="100"/>
>     <column name="RESOURCE_TYPE" javaName="Type" required="true"
> type="VARCHAR" size="100"/>
>     <column name="RESOURCE_TEXT" javaName="Text" required="false"
> type="LONGVARCHAR"/>
>
>     <foreign-key foreignTable="TABLE01">
>         <reference local="REMOTE_ID" foreign="TABLE01_ID"/>
>     </foreign-key>
>     <foreign-key foreignTable="TABLE02">
>         <reference local="REMOTE_ID" foreign="TABLE02_ID"/>
>     </foreign-key>
>     <foreign-key foreignTable="TABLE03">
>         <reference local="REMOTE_ID" foreign="TABLE03_ID"/>
>     </foreign-key>
>     <foreign-key foreignTable="TABLE04">
>         <reference local="REMOTE_ID" foreign="TABLE04_ID"/>
>     </foreign-key>
>     <foreign-key foreignTable="TABLE05">
>         <reference local="REMOTE_ID" foreign="TABLE05_ID"/>
>     </foreign-key>
>     ...(lots of FK mappings)
>     <foreign-key foreignTable="TABLEn">
>         <reference local="REMOTE_ID" foreign="TABLEn_ID"/>
>     </foreign-key>
> </table>
>
>
> <!--Some Table examples -->
> <table name="TABLE01" idMethod="idBroker>
>    <column name="TABLE01_ID" javaName="Id" primaryKey="true"
required="true"
> type="VARCHAR" size="100"/>
>    ...(other stuff)
> </table>
>
> <table name="TABLE02" idMethod="idBroker>
>    <column name="TABLE02_ID" javaName="Id" primaryKey="true"
required="true"
> type="VARCHAR" size="100"/>
>    ...(other stuff)
> </table>
>
>
> <table name="TABLE0n" idMethod="idBroker>
>    <column name="TABLE0n_ID" javaName="Id" primaryKey="true"
required="true"
> type="VARCHAR" size="100"/>
>    ...(other stuff)
> </table>
>
>
>
>
> All my base objects will have unique ID's generated by a modified version
of
> IDBroker, and that's what I use to tie my important tables to any number
of
> miscellaneous Resources via the REMOTE_ID column.  However, for some
reason,
> some of the base objects exhibit the behavior stated above when ant
> project-om is run.
>
> Here is what is even more strange.  Let's say TABLE05 is failing as
> documented above when generating the om.  Now If I were to switch places
> with TABLE01 in the xml schema, the om for TABLE05 generates fine, and
even
> more surprising is that TABLE01 also generates fine also.  Unfortunately,
> this approach does not always fix the problem and sometimes causes other
> objects to generate failing source code that where previously fine.
>
> Any clues?
>
> p.s.
>
> I have tried adding debugging statements to Object.vm, and have found that
> $fk.ForeignLocalMapping.get($col.Name) is returning (in the failing code)
a
> null value meaning that (I think) the Hashtable in ForeignKey that
> represents the foreignColumns is not being fully/correctly  populated for
> some reason.
>
> Scott
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>