Using criteria api I don't know, but if you use hql no sub query is needed I
guess?
A B
1.........0-1
A:
<one-to-one name=.. class="B" />
B:
<id>
<generator class="foreign">
<param name="property">nameOfPropertyToA</param>
</generator>
</id>
<one-to-one name=... class="A" constrained="true" />
HQL
select a from A a left join a.B b where b is null
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Ayende
Rahien
Sent: den 23 september 2008 15:13
To: [email protected]
Subject: [nhusers] Re: Restrictions.IsNull does not work with one-to-one
relations
Please check the documentation for one-to-one, there is a reason we suggest not
using it.
On Tue, Sep 23, 2008 at 2:31 PM, Thomas Koch <[EMAIL PROTECTED]<mailto:[EMAIL
PROTECTED]>> wrote:
Hi Fabio - thank you for your (short) reply. :-)
If I understood it correctly, what you are saying is that you cannot
use a one-to-one mapping between the two classes A and B if B is
sometimes null?
Cheers,
Thomas
On 23 Sep., 12:57, "Fabio Maulo" <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>
wrote:
> 1 to 1 != 1 to 0
> one-to-one = 1 to 1
>
> one-to-many allow from 0 to n
>
> 2008/9/23 Thomas Koch <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>
>
>
>
>
>
>
>
> > Hi there - I am using NH 2.0.
>
> > I am used to using the Criteria API for retrieving objects, but
> > yesterday I ran into problems. I want to find a sub-set of objects of
> > class A whoose one-to-one relation to another class B is null.
>
> > If I use the Restrictions.IsNull of the Criteria API it does not work.
> > I will ask for entities of type B where B.Id IS NULL, which will never
> > happen.
>
> > My setup:
>
> > Class A
> > ID : int
> > Name : string
> > B : B
>
> > Class B
> > ID : int
> > Name: string
>
> > The classes A and B share the same primary key hence I thought it best
> > to use a one-to-one relation for the A.B property.
>
> > I have solved this using HQL using a sub-query but I would still like
> > to know if its possible to do this using the Criteria API.
>
> > Cheers,
> > Thomas
>
> --
> Fabio Maulo- Skjul tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---