hi.

i'm having a problem in setting the value of the id of
a foreign key (which is also the primary key for that
table)

I have a schema that is something like:
        <table  name="Table1">
                <column name="colid"
                        primaryKey="true"
                        required="true"
                        type="INTEGER"
                        autoIncrement="true"/>
                <column name="col"
                        required="true"/>
        </table>

        <table  name="Table2">
                <column name="colid"
                        primaryKey="true"
                        required="true"
                        type="INTEGER"/>
                <column  name="colname"
                        required="true"/>       
        <foreign-key 
                foreignTable="TABLE1"
                onDelete="cascade">
                <reference
                        local="colid"
                        foreign="colid"/>
        </foreign-key>  
        </table>

The point in this schema is that I have a
table(Table2) whose primary key is a foreign key
referencing Table1. That key in table1 is auto
incremented.

In my code, I got the generated colid of Table1 as:
        Table1 table1 = new Table1();
        table1.setCol("some value");
        try { 
            table1.save();
        }catch (Exception e){}
        
        int colid = table1.getColid();

then, i tried to put that value in Table2 (i'm sure
its not a duplicate value):
        Table2 table2 = new Table2();
        try {
                table2.setColid(colid)  //value taken from the Table1
        } catch (TorqueException e) {}
        table2.setColname("some name");
        try { 
            table2.save();
        }catch (Exception e){}

After executing these statements, I noticed that the
colid in table1 is not the same as the colid of
table2. I was able to verify that a TorqueException is
being catched when I set the velue of colid.

I also tried 
        table2.setPrimaryKey(String.valueOf(colid)) instead
of table2.setColid(colid)  but still didn't work.

I tried setting defaultIdMethod to "idbroker", then to
"none" but still has the same problem.

could anyone give some advise on how to solve this
issue?

Many thanks!
Clinton Lopez


                
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to