Hi. Thanks for your help.

Defining javaType as object for a column name seemed like the best solution. 
However the generated classes do not compile. 

The setParentAssetId method now takes a 'Long'  instead of 'long' which will 
help me set it to null. However some methods in the generated bean & data class 
still pass a long to setParentAssetId method ( eg. setParentAssetId(0); ) & it 
does not compile. I am using torque-3.2. 

Any suggestions? 

Shilpa

----- Original Message ----
From: Greg Monroe <[EMAIL PROTECTED]>
To: Apache Torque Users List <torque-user@db.apache.org>
Sent: Tuesday, January 9, 2007 1:56:18 PM
Subject: RE: AW: Setting foreign key column as null

The schema column tag has a javaType attribute that can
be used to specify a single column is to be treated as
an object rather than a primative.  E.g.:

<column name="xxx" javaType="object" .... />

FWIW, some DB server are very strict about foreign key
constraints.  So, your DB server may not let you set
the FK column to NULL.

> -----Original Message-----
> From: Shilpa Kulkarni [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, January 09, 2007 4:10 PM
> To: Apache Torque Users List
> Subject: Re: AW: Setting foreign key column as null
> 
> Thanks for your reply.
> 
> Wouldn't this change other the generated classes as well. 
> There is lot of code already passing primitives to exisiting 
> data classes.  Is there anything that can be  specifically 
> done for this  column? 
> 
> Shilpa
> 
> 
> ----- Original Message ----
> From: Thoralf Rickert <[EMAIL PROTECTED]>
> To: Apache Torque Users List <torque-user@db.apache.org>
> Sent: Tuesday, January 9, 2007 1:45:37 AM
> Subject: AW: Setting foreign key column as null
> 
> Hi!
> 
> Did you try <database defaultJavaType="object">. Then every 
> primitive (long,int,boolean,...) is an object (Long, Integer, 
> Boolean, ...). I think, you cannot set this for a single 
> table. Just for all. 
> 
> bye
> Thoralf
> 
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Shilpa Kulkarni [mailto:[EMAIL PROTECTED]
> > Gesendet: Dienstag, 9. Januar 2007 01:21
> > An: Apache Torque Users List
> > Betreff: Setting foreign key column as null
> > 
> > 
> > I am having trouble setting a foreign key value to null. 
> > Parts of my torque schema file are below. 
> > table_2.parent_asset_id has a foreign key constraint 
> defined on it & 
> > it must be either null or one of the table_1.asset_id column values.
> > 
> >   <table name="table_1"
> >      idMethod="native">
> >     <column
> >       name="asset_id"
> >       required="true"
> >       primaryKey="true"
> >       type="BIGINT"
> >       description="ASSET ID"/>
> >   </table>
> > 
> > 
> >   <table name="table_2"
> >      idMethod="none">
> >     <column
> >       name="parent_asset_id"
> >       required="false"
> >       primaryKey="false"
> >       type="BIGINT" />
> > 
> > <!-- Some other columns defined here. -->
> > 
> >     <foreign-key foreignTable="table_1">
> >       <reference
> >         local="parent_asset_id"
> >         foreign="asset_id"/>
> >     </foreign-key>
> >   </table>
> > 
> > I want to be able to write code as follows:
> > 
> > Table2Bean table2Bean = new Table2Bean(); 
> > table2Bean.setParentAssetId(null);
> > 
> > However the setParentAssetId method in generated bean class 
> takes has 
> > input parameter of type 'long'. So passing null does not work.
> > 
> > The generated method in Table2Bean class looks like this:  
> > public void setParentAssetId(long v)
> >     {
> >   
> >         this.parentAssetId = v;
> >         setModified(true);
> > 
> >     }
> > 
> > 
> > If the generated method was taking an object paramter (Long 
> instead of 
> > long), it would work.
> > 
> > Any idea how to make it work? Any help is appreciated.
> > 
> > Shilpa
> > 
> > 
> > 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around 
> > http://mail.yahoo.com
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection 
> around http://mail.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are 
confidential communication or may otherwise be privileged or confidential and 
are intended solely for the individual or entity to whom they are addressed.  
If you are not the intended recipient you may not rely on the contents of this 
email or any attachments, and we ask that you  please not read, copy or 
retransmit this communication, but reply to the sender and destroy the email, 
its contents, and all copies thereof immediately.  Any unauthorized 
dissemination, distribution or copying of this communication is strictly 
prohibited.



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






 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

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

Reply via email to