You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Eric Emminger <er...@ericemminger.com> on 2002/09/25 00:03:40 UTC

NumberKey for foreign-key should be null

If a foreign key is null in the database, I would expect the accessor on
the object for the foreign key to also return null. Instead, I'm getting
an initialized NumberKey with a null BigDecimal. Shouldn't the accessor
return null as I would expect?

Here's an example.

I have a Turbine 2.1 Torque-generated business object with an INTEGER
property that's a foreign key to another object. When I retrieve an
object from the database, where the value of the INTEGER property is
null, the NumberKey for the property of the object is _not_ null. I
would expect it to be null, matching the value in the database. Why
isn't it?

For clarity, the schema looks like this.

<table name="businessObject">
  <column name="integerProperty" type="INTEGER"/>
  <foreign-key foreignTable="relatedObject">
    <reference local="integerProperty" foreign="primaryKey"/>
  </foreign-key>
</table>

So, when I get a BusinessObject bo from the database, as in

BusinessObject bo = BusinessObjectPeer.retrieveByPK(new NumberKey(1));

where the value of integerProperty in the database is null,
bo.getIntegerProperty() returns a NumberKey with a null BigDecimal,
instead of returning null. Shouldn't the accessor return null as I would
expect?

I'm using the Turbine TDK 2.1 and MySQL 3.23.48. Could this be a problem
with MySQL?

Eric

-- 
Eric Emminger
eric@ericemminger.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>