NRE is a bug, please create a test case and add it to the JIRA.
In the meantime, you can use CreateCriteria(typeof(SpecialOrder))

On Mon, Sep 22, 2008 at 9:59 PM, Jon Palmer <[EMAIL PROTECTED]> wrote:

> I would appreciate some help combining logical expressions in criteria
> queries.
> My toy object model is three classes
>
> Order and a subclass SpecialOrder
> Person
>
> each Order has a Person property. I'm trying to do a query for all Orders
> where the order is of type special order or where the Order.Person is not
> deleted. I've tried this:
>
> DetachedCriteria detached= DetachedCriteria.For(typeof(Person), "p")
> .Add(Property.ForName("p.IsDeleted").Eq(false));
> ICriteria criteria = session.CreateCriteria(typeof (Order))
> .Add(Restrictions.Or(
>      Property.ForName("class").Eq(typeof(SpecialOrder)),
>      Property.ForName("Person").Eq(detached)
>      )).List();
>
>
> but I get a null Reference exception in:
> "NHibernate.Criterion.SubqueryExpression.InitializeInnerQueryAndParameters(ICriteriaQuery
> criteriaQuery)"
>
>
> Any thoughts on how to get this kind of query right?
>
> Thanks
> Jon
>
>
> P.S. I'm expecting that the sql generated should look something like this:
>
> select .... from Orders o, left out join Persons p on o.PersonID = p.ID
> where
> o.Class = 'SpecialOrder' or (o.PersonID is not null and p.IsDeleted = 0)
>
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to