-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Projection.Property of dictionary key
PostPosted: Mon Feb 07, 2011 6:56 am 
Newbie

Joined: Mon Feb 07, 2011 6:00 am
Posts: 1
Hi,

I am struggling to construct an HCQ, and would appreciate any help that you may able to give me.

Lets start with the mapping for the "Item" entity:

Code:
        <map name="NumberRequiredPerDay" lazy="false">
            <key column="ItemId"></key>
            <index column="Date" type="DateTime"></index>
            <element type="int" column="NumberRequired"></element>
        </map>


I have another query which uses a subquery containing a distinct list of Dates which have a NumberRequired > 0 from the Item entity.

To achieve this, I have constructed the following HCQ:

Code:
   DetachedCriteria SubQuery = DetachedCriteria.For<Item>()
      .SetProjection(Projections.ProjectionList()
         .Add(Projections.Property("NumberRequiredPerDay.Date")) // Understandably does not work, but not sure what to replace it with.
      )
      .Add(Restrictions.Eq("ID", ID))
   ;

   return session.CreateCriteria<OtherItem>()
                // Other Query Criteria Goes Here
      .Add(Subqueries.PropertyIn("OtherItem.Dates.Date", SubQuery))
      .List<OtherItem>();


However, I cannot find a way to project the Date value from the Item entity in the subquery, as commented in the code above.

I would really appreciate it if someone could lend a hand.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.