You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Richard Schuller <dr...@yahoo.com> on 2004/02/06 23:54:46 UTC

Object vs Primitive Type declaration for nullable columns

I have a class A representing table TA�defined as
follows:
�
class A {
....
�private long sourceId;
�private Long targetId;
...
TCorporation source;
TCorporation target;
}
�
where sourceId,targetId,source and target represent
primary keys/rows respectively in the T_C table.
�
Table TA has target_id column defined as nullable.
�

In the repository.xml file I have declared the
following:
�
...

<field-descriptor name="sourceId"
column="source_corp_id" jdbc-type="BIGINT"/> 

<field-descriptor name="targetId"
column="target_corp_id" jdbc-type="BIGINT"/>

...
<reference-descriptor
name="source"
class-ref="vo.TCorporation">
<foreignkey field-ref="sourceId"/>
</reference-descriptor>

<reference-descriptor
name="target"
class-ref="vo.TCorporation">
<foreignkey field-ref="targetId"/>
</reference-descriptor>
...

I am setting the sourceId and targetId to the
appropriate values.

When I am attempting to store a record of type A, I
can see that the sourceId is populated correctly in
the INSERT statement, but the targetId is null.

If I change the type from Long to primitive type long,

than the targetId is populated correctly.

I cannot have targetId defined as long because it is a
nullable field.

How do I have to declare targetId in order to achive
the above?

Thanks in advance,
Richard

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org