-->
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: Simple HQL statement not working !?
PostPosted: Fri May 07, 2010 4:15 pm 
Newbie

Joined: Tue Feb 16, 2010 6:57 pm
Posts: 17
Hi,

I have a simple HQL query statement that I expect to work with no problem but I just could not get thru this queryException. I hope extra pair of eyes can help spot my wrong doings right away.

Cause of Exception:
org.hibernate.QueryException: Not all named parameters have been set: [conId] [SELECT Consumer FROM Consumer AS consumer WHERE consumer.conId = :conId]

Code:
Code:
   public static Consumer findConConsumer(Long conId) {
   if (conId == null)
   return null;
      return (Consumer) entityManager().createQuery("SELECT Consumer FROM Consumer AS consumer WHERE consumer.conId = :conId").getSingleResult();
      //return (Consumer) entityManager().createQuery("select o from Consumer o as o where o.conId = :con_Id").getSingleResult();


I debugged to make sure that [conId] was indeed passed in and with the right value. Indeed it was.

Any ideas and info would be greatly appreciated.


Top
 Profile  
 
 Post subject: Re: Simple HQL statement not working !?
PostPosted: Fri May 07, 2010 4:49 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
...createQuery(.....).setLong("conId", conId).getSingleResult();


Top
 Profile  
 
 Post subject: Re: Simple HQL statement not working !?
PostPosted: Fri May 07, 2010 7:56 pm 
Newbie

Joined: Tue Feb 16, 2010 6:57 pm
Posts: 17
Thank you so much. It worked right away.

p.s. I just substituted setLong() to setParameter()

Your help is greatly appreciated.


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.