SUMMARY
We suspect there is a bug in the updating of referenced objects. When the
foreign key is updated on the parent object the reference is not updated and
is left pointing to the original referenced object.
DETAIL
I have two tables one called Exchange and one called Country
Exchange has a countryID which joins on country.
I am using the xml at the end of this mail to map this.
I have written the Exchange class, the Country class the Country interface
and the CountryProxy.
This works for reading values from Country via Exchange.
However when I change the value of countryID in the Exchange java Object
inside a transaction
(see java code below) then after the transaction has been committed the
countryID has changed, but the
link is to the same country object.
<class-descriptor
class="org.apache.ojb.tutorial1.Exchange"
table="Exchange">
<field-descriptor id="1"
name="exchangeID"
column="ExchangeID"
jdbc-type="INTEGER"
primarykey="true"
/>
<field-descriptor id="2"
name="countryID"
column="CountryID"
jdbc-type="INTEGER"
/>
<field-descriptor id="3"
name="code"
column="Code"
jdbc-type="VARCHAR"
/>
<field-descriptor id="4"
name="description"
column="Description"
jdbc-type="VARCHAR"
/>
<reference-descriptor
name="country"
class-ref="org.apache.ojb.tutorial1.Country"
auto-update="true"
auto-retrieve="true"
auto-delete="true"
>
<foreignkey field-id-ref="2"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor
class="org.apache.ojb.tutorial1.Country"
-- proxy="org.apache.ojb.tutorial1.CountryProxy"
table="Country">
<field-descriptor id="1"
name="countryID"
column="CountryID"
jdbc-type="INTEGER"
primarykey="true"
/>
<field-descriptor id="2"
name="majorCurrency"
column="MajorCurrency"
jdbc-type="VARCHAR"
/>
<field-descriptor id="3"
name="description"
column="Description"
jdbc-type="VARCHAR"
/>
<field-descriptor id="4"
name="regionID"
column="RegionID"
jdbc-type="INTEGER"
/>
</class-descriptor>
CountryProxy country = exchange.getCountry();
System.out.println(country.getDescription());
try
{
broker.beginTransaction();
exchange.setCountryID(8);
broker.store(exchange);
broker.commitTransaction();
System.out.println("new exh country id " +
exchange.getCountryID());
country = exchange.getCountry();
System.out.println(country.getDescription());
----------------------------------------------------------------------
If you have received this e-mail in error or wish to read our e-mail
disclaimer statement and monitoring policy, please refer to
http://www.drkw.com/disc/email/ or contact the sender.
----------------------------------------------------------------------