-->
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.  [ 6 posts ] 
Author Message
 Post subject: Using the IN directive in the where clause
PostPosted: Tue Jul 26, 2005 3:02 pm 
Newbie

Joined: Tue Jul 26, 2005 2:45 pm
Posts: 2
Hello,
I am trying to do the following query:

Code:
query = aManager.createQuery("from Group g where g.id in (:aGroupIDList)");
query.setParameter("groupIdList", aGroupIDList);




when I test this code by passing in the following ArrayList
Code:
List groupIdArray = new ArrayList();
    groupIdArray.add(0);
    groupIdArray.add(1);
    groupIdArray.add(2);
    groupIdArray.add(3);
    groupIdArray.add(4);



I get the following error:

Caused by: java.sql.SQLException: Wrong data type: For input string:
Code:
"[B@8cca2a"
   at org.hsqldb.jdbc.jdbcUtil.throwError(Unknown Source)
   at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source)
   at org.hsqldb.jdbc.jdbcPreparedStatement.setBytes(Unknown Source)
   at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setBytes(WrappedPreparedStatement.java:424)
   at org.hibernate.type.BinaryType.set(BinaryType.java:29)
   at org.hibernate.type.SerializableType.set(SerializableType.java:29)
   at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:62)
   at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:44)
   at org.hibernate.loader.hql.QueryLoader.bindNamedParameters(QueryLoader.java:236)
   at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1105)
   at org.hibernate.loader.Loader.doQuery(Loader.java:365)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
   at org.hibernate.loader.Loader.doList(Loader.java:1515)



Additional Info:
Group.id is an int value


If I hard code the values as follows the code works as expected:

Code:
query = aManager.createQuery("from Group g where g.id in (1,2,3)");


My question then is the following: how do I parametrically pass in to the query the values for the "in" operator?

Code:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 6:29 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hum, I thought I handled this case properly, please provide me a runnable testcase and put it to JIRa, I'll check it.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 6:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Note that the EJB spec does not demand support for this case (though I am trying to get it in).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 2:45 am 
Beginner
Beginner

Joined: Fri Feb 11, 2005 12:03 pm
Posts: 48
Location: Kiel, Germany
Shouldn't it be
Code:
query.setParameterList("aGroupIdList", aGroupIDList);
?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 5:37 am 
Newbie

Joined: Tue Jul 26, 2005 2:45 pm
Posts: 2
Your right, it should be:

Code:
query.setParameterList("aGroupIdList", aGroupIDList);



However that was a typo in my posting to the forum, the error that I describe still stands.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 1:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
hug, you're not using EntityManager???

_________________
Emmanuel


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