Hi,

 

It looks like OJB cannot fetch correctly records which have a BigInt primary
key with value 0; at least in the following conditions;

 

- I'm using RC5

- Have a table (here Locations) with a primary key Id with a auto-increment
sequence

- I'm using Oracle 9.2

- The table has a 1-N collection using a proxy.

 

 

For instance, I have the following mapping:

 

                <class-descriptor class="Locations" table="LOCATIONS">

 

            <field-descriptor name="id" column="ID" 

jdbc-type="BIGINT" primarykey="true" 

autoincrement="true" 

sequence-name="locations_id_seq"/>

 

            <field-descriptor name="latitude" column="LATITUDE"
jdbc-type="BIGINT"/>

 

            <field-descriptor name="longitude" column="LONGITUDE"
jdbc-type="BIGINT"/>

            ...

            <collection-descriptor name="collElements" 

element-class-ref="Elements" proxy="true">

                  <inverse-foreignkey field-ref="locationid"/>

            </collection-descriptor>

 

      </class-descriptor>

 

 

Now in the database, there is a location with Id=0.

When I use OJB to fetch this record (with a criteria on Id=0), the resulting
instance is correct except for the Id field which has the next sequence
value.

 

Tracing the code, what happens is when the query is executed:

 

-          RsIterator.getObjectFromResultSet reteive the simple fields
correctly

-          As there is a collection, retrieveCollections is called

-          The query to retrieve the collection is built: Query fkQuery =
getFKQuery(obj, cld, cds); 

-          This retrieves the PK fields values (getFKQuery1toN ) which
indirectly calls getValuesForObject 

-          When the value for the Id is retrieved (getAutoIncrementValue),
it is considered as Null (BrokerHelper.isNull) and thus the sequence is
called.

 

Can this be considered a bug?

Are there any workarounds?

 

 

Thanks,

 

-Alex

 

Reply via email to