I solved this problem by specifying as o. "select distinct c from Customer c , c.Orders.elements as o where o.OrderDate > :orderDate" ------Original Message------ From: RobB Sender: [email protected] To: nhusers ReplyTo: [email protected] Subject: [nhusers] Populating child collections in HQL - Summer of Nhibernate 06 - Elements Sent: Dec 7, 2009 10:18 AM
Hi, I've been working through the screen casts Steve B. put together building up to using Nhibernate on my next project. I'm up to Session 6, Advanced Querying of Child Collections and have hit a problem when trying to get Steve's HQL example to work. I know Steve frequents this group and there is a blog for SOH but thought I'd ask in here as I've just registered for the group and thought my idiotic question would act as a good introduction. Anyway the idea was to retrieve a customer and a collection of their orders, where the orders were placed after a given date. The HQL was : "select distinct c from Customer c , c.Orders.elements o where o.OrderDate > :orderDate" I was getting an error of "c.Orders.elements is not mapped". I had a dig around and it seemed that the syntax for getting a collection of elements had changed, the correct syntax would be "elements (c.Orders)". I tried using this but then got an "Antlr.Runtime.MissingTokenException". I couldn't find any further examples without an explicit join on the child objects and so have ended up using the following : "Select distinct c from Customer c inner join fetch c.Orders o where o.OrderDate > :orderDate" I'd much rather use a construct along the lines of the first HQL statement with an implicit join and I know I probably can't see the wood for the trees. Can anyone give me any pointers on this one? Many thanks Rob -- 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. Sent via BlackBerry -- 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.
