I agree, that does not look nice.
However, as far as i know your example should work, at
least it does for me.  Granted, I still use field id's instead of
field names, but that should not make a difference I think ?
Have you looked at the generated SQL for a clue about what
went wrong ?

Cheers,
        Theo




> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Verzonden: maandag 17 maart 2003 15:40
> Aan: [EMAIL PROTECTED]
> Onderwerp: query for null reference (= foreign key) fields
>
>
> Hello,
>
> I have observed a behaviour in the PB query engine which
> could be improved in my opinion.
>
> I have a persistence-capable class 'Node' with a reference
> 'parentNode' of type 'Node' (suitable to build a tree).
>
> As usual with OJB, there is a (private) field 'parentNode_refid'
> whose type corresponds to the primary key of class Node.  (long
> in my case.)  Here is a excerpt from my repository.xml:
>
> <field-descriptor name="parentNode_refid" ... />
> <reference-descriptor name="parentNode" class-ref="Node">
>   <foreignkey field-ref="parentNode_refid"/>
> </reference-descriptor>
>
> I want to formulate a query for all nodes that do not
> have a parent node.  What I consider canaconical from the
> documentation was:
>
> criteria.addIsNull("parentNode"); // does not work
>
> But that does not work.  Unfortunately, I does not through
> an exception either.  The query will just return no objects.
>
> What I have to write is:
>
>     crit.addEqualTo("parentNode_refid", new Integer(0));
>
> which is somewhat ugly because it uses the "secret" auxiliary
> reference which I would like to hide from the developer.
> (It is no big deal for our project because we have a
> layer on top of OJB where I can easily hide this.)
>
> What do you think?
>
> Olli
>
>
> --
>   Oliver Matz
>   ppi Media GmbH
>   Deliusstra�e 10
>   D-24114 Kiel
>   phone       +49 (0) 43 1-53 53-422
>   fax         +49 (0) 43 1-53 53-2 22
>   email       mailto:[EMAIL PROTECTED]
>   web www.ppi.de
>
>
> ---------------------------------------------------------------------
> 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