Thank you Armin.  I am thinking about what you said.   I kinda figured what you 
said was happening, but didn't know a best way around it.  Thank you for the 
options.  I think in the end I might have to choose the first solution, but not 
sure yet.

I follow you guys on the dev list and can't wait to play with 1.0.2 potentially 
this weekend.  It is a lot of good creative work and I am trying to learn about 
OJB internals through the discussions you go through there.

Cheers.

JohnE


----- Original Message -----
From: Armin Waibel <[EMAIL PROTECTED]>
Date: Saturday, March 12, 2005 6:00 pm
Subject: Re: NULL is ok problem.

> Hi,
> 
> the problem is that FK 'countryid' is used for Region and Country. 
> If 
> OJB doesn't find a Region on update of the main object and auto-
> update 
> set to 'link' it nullify all FK fields of Region (regionid, 
> countryid) 
> in the main object.
> 
> - Set auto-update/auto-delete to 'none' in reference-descriptor 
> "region". In this case you have insert/update/delete Region 
> objects "by 
> hand" - "link by hand".
> http://db.apache.org/ojb/docu/guides/basic-
> technique.html#Link+references
> - Use different countryid FK fields -> countryid, countryRegionId. 
> You 
> can declare the new 1:1 FK field 'countryRegionId' as anonymous, 
> then 
> you don't have to change your persistent object class (but you 
> need 
> another column in main object table)
> 
> - Avoid the composed PK in Region and make a single PK
> 
> regards,
> Armin
> 
> [EMAIL PROTECTED] wrote:
> > I have a pretty large system running OJB which works well, but 
> now I am trying to internationalize it.  I have a problem.
> > 
> > country->region->local  is the new general object mapping.
> > 
> > Previously in our last release we just had US and the states, 
> but now the mapping doesn't seem to work.
> > 
> > The problem is for many countries, there are no regions.  When I 
> go to update/insert a record without a region, it is now nulling 
> out the country.  I believe this is because OJB requires the 
> region to be non-null.  I do resolve references before the update, 
> but where regionId is null there can be no region object.
> > 
> > Right now the mapping looks as follow.  I don't map local yet as 
> there is no need yet.   I would be interested in knowing if this 
> is possible if region is null as well.
> > 
> > I believe what I need is that "NULL" be ok for a key.   I need 
> some guidance on what I can do.
> > 
> > 
> > 
> > Here are the pertinent fields:
> > 
> > ---------
> >     ... lots of other fields
> > 
> >     <field-descriptor
> >         name="countryId"
> >         column="countryid"
> >         jdbc-type="CHAR"
> >     />
> >     <field-descriptor
> >         name="regionId"
> >         column="regionid"
> >         jdbc-type="CHAR"
> >     />
> >     <field-descriptor
> >         name="localId"
> >         column="localid"
> >         jdbc-type="CHAR"
> >     />
> > 
> >     <reference-descriptor
> >             name="country"
> >             class-ref="com.jb.sp.model.places.CountryVO"
> >             auto-retrieve="true"
> >             auto-update="link"
> >             auto-delete="none"
> >             proxy="false">
> >         <foreignkey field-ref="countryId"/>
> >     </reference-descriptor>
> > 
> >     <reference-descriptor
> >             name="region"
> >             class-ref="com.jb.sp.model.places.RegionVO"
> >             auto-retrieve="true"
> >             auto-update="link"
> >             auto-delete="none"
> >             proxy="false">
> >         <foreignkey field-ref="countryId"/>
> >         <foreignkey field-ref="regionId"/>
> >     </reference-descriptor>
> > 
> > ---------
> > 
> > <class-descriptor class="com.jb.sp.model.places.CountryVO" 
> table="country">>     <field-descriptor name="countryId" 
> column="CountryCode" jdbc-type="CHAR" primarykey="true"/>
> >     <field-descriptor name="name" column="CountryName" jdbc-
> type="VARCHAR"/>> </class-descriptor>
> > 
> > 
> > <class-descriptor class="com.jb.sp.model.places.RegionVO" 
> table="region">>     <field-descriptor name="countryId" 
> column="SUCountry" jdbc-type="CHAR" primarykey="true"/>
> >     <field-descriptor name="regionId" column="SUCode" jdbc-
> type="CHAR" primarykey="true"/>
> >     <field-descriptor name="name" column="SUName" jdbc-type="VARCHAR"/>
> > </class-descriptor>
> > 
> > 
> > 
> > 
> > 
> > -----------------------------------------------------------------
> ----
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> > 
> 
> -------------------------------------------------------------------
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to