-->
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: NamedQuery parameter error
PostPosted: Fri Jun 05, 2009 11:45 am 
Newbie

Joined: Fri Jun 05, 2009 11:30 am
Posts: 2
I have a named query:-
@NamedQueries ( {
@NamedQuery(name="byOwners", query="select e from SchedulerEntry e where e.owner.id in ( :loginIdList )")
})

I am calling it like this:-
public List<SchedulerEntry> findEntriesFor(List<Long> owners) {
Query query = getCurrentSession().getNamedQuery("byOwners");
query.setParameter("loginIdList", loginIds);
List<SchedulerEntry> result = query.list();
return result;
}

I get this error:-
Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Long
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:116)
at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:38)

I think I must be doing something stupid but I can't figure out where.

Could someone please tell me where I am going wrong?


Top
 Profile  
 
 Post subject: Re: NamedQuery parameter error
PostPosted: Fri Jun 05, 2009 11:49 am 
Newbie

Joined: Fri Jun 05, 2009 11:30 am
Posts: 2
Apologies I realised my mistake.
I should be using a syntax like this:-

q.setParameterList("namesList", names);


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.