-->
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.  [ 2 posts ] 
Author Message
 Post subject: error with named parameter in elements function
PostPosted: Wed Jun 30, 2004 6:41 pm 
Newbie

Joined: Mon May 10, 2004 5:45 pm
Posts: 9
I have an HQL query that looks like this:
<query name="com.rsm.dao.hibernate.UserDAOHibernate.users.by.userNames"><![CDATA[from com.rsm.domain.usermanagement.PersonImpl as user where user.userName in elements(:userNames)]]></query>

With the following code using it below:

public List getUsersByUserNames(List userNames) throws DAOException {
List users = null;
if(userNames!=null) {
String[] paramNames = {"userNames"};
Object[] paramValues = {userNames};
Type[] typeParams = {Hibernate.SERIALIZABLE};
users = getHibernateTemplate().
findByNamedQuery(
"com.rsm.dao.hibernate.UserDAOHibernate.users.by.userNames",
paramNames,
paramValues,
typeParams);
}
return users;
}

I get the following error:
Named parameter does not appear in Query: userNames [from com.rsm.domain.usermanagement.PersonImpl as user where user.userName in elements( :userNames )]; nested exception is net.sf.hibernate.QueryException: Named parameter does not appear in Query: userNames [from com.rsm.domain.usermanagement.PersonImpl as user where user.userName in elements( :userNames )]

Is there an issue with using named parameters inside the elements function?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 02, 2004 12:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Yes. Thats not the purpose of the elments() call. The query you probably are looking for is:

from PersonImpl as user where user.userName in (:userNames)


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