-->
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.  [ 4 posts ] 
Author Message
 Post subject: Expression.In problem
PostPosted: Fri May 13, 2005 11:27 pm 
Beginner
Beginner

Joined: Fri May 13, 2005 11:21 pm
Posts: 21
Location: Atlanta, GA
I have a datagrid that has check boxes to filter the "statuses" of orders the administration wishes to see.

The statuses 1 - pending, 2 - shipped, 3 - cancelled and 4 - shipped.

The Order object and mapping correctly loads a Order object and OrderState object (which is in another table)

When I try and do a Expression based criteria I create a int array of each status I want to be in the "set" and then I call the criteria method

for example

int[] states = new int {1.4};

IList Orders = session.CreateCriteria(typeof(Order)).Add(Expression.In("Status.OrderStatusId", states )).List();

Order.Status.OrderStatusId will match one of those integers, however when I run the query I get the following exception :

{"unresolved property: Status.OrderStatusId []" } System.Exception

The class Order has a member called Status of type OrderStatus which has a Name and orderStatusId , for some reason the Expression is being evaluated as if I was inferrring orderStatusId was an array which it isn't and I wasn't trying to either :)


What am I doing wrong ?

Thanks
Grant


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 15, 2005 11:53 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 12:59 pm
Posts: 20
It can't parse through properties of properties. Only "Status" would be valid in an ICriteria.

You can to use hql to do what you're wanting to do.

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 16, 2005 9:16 am 
Thanks mike, I'll take a look at HQL.


Top
  
 
 Post subject:
PostPosted: Sun May 22, 2005 1:16 pm 
Beginner
Beginner

Joined: Fri May 13, 2005 11:21 pm
Posts: 21
Location: Atlanta, GA
I ended up fixing this using HQL and the "in" keyword and posted the solution to my blog

http://theresidentalien.typepad.com/ginormous/2005/05/using_a_in_set_.html


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

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.