I found the problem, my diagnostic was not correct, it happens with criteria and HQL the same. I filed a bug in JIRA. IMHO NHibernate should fail in a more elegant way if this can't be done.
http://216.121.112.228/browse/NH-2177 On Apr 14, 5:35 pm, Marc Climent <[email protected]> wrote: > Hi all. > > I wasn't able to find information on a problem I'm facing. The > following Criteria query works perfectly for me: > > var query = session.CreateCriteria(typeof (Content)); > > query.Add(Property.ForName("Parent").Eq(parent)); > query.Add(Property.ForName("class").Eq(typeof(ContentSubclass)); > > var list = query.List<Content>(); > > Where content has many subclasses (with joined-subclass mapping) and I > want to get only the Children of a specified type. > > If I use HQL instead of Criteria, I think it should read: > > var queryString = "from Content as c where c.Parent=:parent and > c.class=:clazz"; > > var query = session.CreateQuery(queryString); > > query.SetParameter("parent", parent); > query.SetParameter("clazz", typeof(ContentSubclass)); > > var list = query.List<Content>(); > > In this case, it throws a SQL error, because the class is passed as a > String and tries to be converted to an Int32 when NHibernate is > creating the parametrized query. > > I can work with Criteria, but this behavior seemed strange to me, did > I miss something? > > Thanks. -- 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.
