Hi Jakob,

I just checked and you are right. 

Nevertheless I find a lot of statements like SELECT ... FROM ... WHERE 
id='' in my P6Spy logs, where id is a not nullable primary key. I was 
assuming these were generated from resolving references with FK=null, but 
it turns out this is wrong. Looks like I'll have to do a little more 
research to find the reason for these selects...

Regards,
Gerhard





Jakob Braeuchi <[EMAIL PROTECTED]>
15.10.2003 16:10
Bitte antworten an "OJB Users List"

 
        An:     OJB Users List <[EMAIL PROTECTED]>
        Kopie: 
        Thema:  Re: Antwort: RE: How to map optional 1:1 relationship


hi gerhard,

imo this is already implemented. see 
PersistenceBrokerImpl#getReferencedObject:

...
         // BRJ: check if we have non null pk values
         // TBD  we should also check primitives
         // to avoid creation of unmaterializable proxies
         for (int i = 0; i < pkVals.length; i++)
         {
             if (pkVals[i] != null)
             {
                 allPkNull = false;
                 break;
             }
         }
         // BRJ: if all pk values are null there's no referenced object
         if (allPkNull)
         {
             return null;
         }
...

hth
jakob

[EMAIL PROTECTED] wrote:

> Hi,
> 
> If I may add a note: 
> 
> It's certainly good to avoid primitives for FK fields, but the 
unnecessary 
> SELECT statements with WHERE FK=null are
> currently generated also when using non-primitives such as Integer. It 
> would be nice if this could be avoided.
> 
> Regards,
> Gerhard
> 
> 
> 
> 
> 
> [EMAIL PROTECTED]
> 15.10.2003 13:24
> Bitte antworten an "OJB Users List"
> 
> 
>         An:     [EMAIL PROTECTED]
>         Kopie: 
>         Thema:  RE: How to map optional 1:1 relationship
> 
> 
> Hello,
> 
> 
>>-----Original Message-----
>>From: Boyes, Carl [mailto:[EMAIL PROTECTED]
> 
> 
>>I've currently
>>mapped it as a 1:1, but the when the foreign key reference is 
>>null an extra sql statement with a where condition of 
>>               fkey = ''
>>is generated.
> 
> 
> this question has been asked fairly often
> (for example by myself).  See e.g. thread
> "Null references and proxies".
> 
> The solution is to use java reference types
> as foreign key fields (unlike in the OJB 
> examples / junit tests), Integer instead of int.
> 
> I can really highly recommend that.
> 
> Olli
> 
> ---------------------------------------------------------------------
> 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