Hi Shiva,

you have to call 'db.create(table2);' before your call to
'db.create(table1);'.

It may also be neccassary to make your properties of classes table1 and
table2 public or provide public getter/setter methods which would be
better style. They should look like:

public int getA() { return _a; }
public void setA(int a) { _a = a; }

Regards
Ralf



Shiva P. Kodityala schrieb:
> Trying to insert row in table1. table1 references table2. Do I need to 
> specify this relation in table definition?
> 
> table1 - test.Table1
> table2 - test.Table2
> 
> Error- Application is inserting rows in table1; not in table2; It should make 
> an insert in Table2 also..right?
> Am I making any mistake in mapping.xml? Please help
> 
> 
>                       Code to test the inserts:
> 
>                       Database db = null;
>                       JDO jdo = new JDO();
>                       String dbName = "databasename";
>                       String databaseXml = "/home/castor/database.xml";
>                       System.out.println(databaseXml);
>                       jdo.setConfiguration( databaseXml);
>                       jdo.setDatabaseName( dbName );
>                       db = jdo.getDatabase();
>                       db.begin();
>                       Table2 table2 = new Table2(13, "13");
>                       Table1 table1 = new Table1(13, 13, "Twelve13", table2);
>                       db.create(table1);
>                       db.commit();
>                       db.close();
> 
> 
> 
> 
> SQL> desc table1;
>  Name                            Null?    Type
>  ------------------------------- -------- ----
>  A                               NOT NULL NUMBER
>  B                                        VARCHAR2(10)
>  D                                        NUMBER
>  TABLE2                                   NUMBER
> 
> SQL> desc table2;
>  Name                            Null?    Type
>  ------------------------------- -------- ----
>  A                               NOT NULL NUMBER
>  C                                        VARCHAR2(10)
> 
> SQL> 
> 
> package test;
> public class Table2 implements java.io.Serializable{
> 
>       int _a;
>       String _c;
>       /**
>        * Constructor for Table2.
>        */
>       public Table2() {
>               super();
>       }
> 
>       public Table2(int a, String c) {
>               this._a = a;
>               this._c = c;
>       }
> 
> ---
> ---
> package test;
> public class Table1 implements java.io.Serializable {
> 
>       int _a;
>       int _d;
>       String _b;
>       Table2 _table2;
>       /**
>        * Constructor for Table1.
>        */
>       public Table1() {
>               super();
>       }
> 
>       public Table1(int a, int d, String b, Table2 table2)
>       {
>               this._a = a;
>               this._d = d;    
>               this._b = b;
>               this._table2 = table2;
>       }
> ---
> ---
> --
> 
> <mapping>                                            
>   <class name="test.Table2" identity="a">   
>     <description>Table2</description>                
>     <map-to table="Table2"/>                         
>     <field name="a" type="integer">                  
>       <sql name="A" type="integer"/>                 
>     </field>                                         
>     <field name="c" type="string">                   
>       <sql name="C" type="varchar"/>                 
>     </field>                                         
>   </class>                                           
>                                                      
>   <class name="test.Table1" identity="a">   
>     <description>Table1</description>                
>     <map-to table="Table1"  />                       
>     <field name="a" type="integer" >                 
>       <sql name="A" type="integer"/>                 
>     </field>                                         
>     <field name="b" type="string">                   
>       <sql name="B" type="char" />                   
>     </field>                                         
>     <field name="d" type="integer">                  
>       <sql name="D" type="integer" />                
>     </field>                                          
>     <field name="table2" type="test.Table2"> 
>       <sql name="table2"  />                          
>     </field>                                          
>   </class>                                            
>                                                       
> </mapping>                                            
> 
> -------------------------------------------------
> If you wish to unsubscribe from this list, please 
> send an empty message to the following address:
> 
> [EMAIL PROTECTED]
> -------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to