Ok I will file the JIRA ticket. I'm not sure how I would
use CreateCriteria(typeof(SpecialOrder)). I want my result set to inlcude
Orders that are not SpecialOrders but do have a non-deleted Person.
Suppose the left join of the Orders and Parties table looks like this

Order.ID | Order.Class   | Order.PersonID | Person.ID | Person.IsDeleted

     1      | SpecialOrder |    1                   |    1          |    0
     2      | SpecialOrder |   2                    |    2          |    1
     3      | SpecialOrder |   null                 |    null      |    null
     4      | Order            |    1                   |    1          |
 0
     5      | Order            |    2                   |    2          |
 1


I would expect to get back the first 4 orders but not order 1.

Thanks
Jon

On Mon, Sep 22, 2008 at 12:04 PM, Ayende Rahien <[EMAIL PROTECTED]> wrote:

> 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