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.  [ 3 posts ] 
Author Message
 Post subject: HQL List Parameter
PostPosted: Thu Aug 14, 2008 1:39 pm 
Newbie

Joined: Thu Aug 14, 2008 1:09 pm
Posts: 2
Hi, I am trying to pass a list of integers into an HQL statement:

Code:
SELECT schedule
from BillableSchedule as schedule
where schedule.Id in :scheduleIdList


I have tried passing :scheduleIdList as an array of ints and also as a list. When I turn on SQL Profiler, I see the parameter is passed in as varbinary data. The documentation shows that this is supported:

Code:
from Eg.DomesticCat cat where cat.Name in ( 'Foo', 'Bar', 'Baz' )


Is there a way to do the same thing with a list of items as a parameter:

Code:
from Eg.DomesticCat cat where cat.Name in :fooBarList


Thanks!

Noel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 14, 2008 2:26 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Try

"from Eg.DomesticCat cat where cat.Name in (:fooBarList)"

and

query.SetParameterList(list);

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Thu Aug 14, 2008 2:31 pm 
Newbie

Joined: Thu Aug 14, 2008 1:09 pm
Posts: 2
I was just about to post that I found my problem. My two issues were those that you described:

1.) I was using SetParameter instead of SetParameterList. This was causing the varbinary issue. I didn't see the SetParameterList operation because I am using a light wrapper around nHibernate that didn't expose the SetParameterList method.
2.) There was a syntax error in the HQL (I hadn't wrapped the parameter in parenthesis.

Thanks very much for you accurate and speedy response!

Best,
Noel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.