You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Shilpa Kulkarni <sh...@yahoo.com> on 2007/01/09 01:20:59 UTC
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: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org