-->
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: Problems with Query interface
PostPosted: Tue Jan 20, 2004 10:23 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
I'm using Hibernate 2.1.1.
I'm trying to use the Query interface to obtain information.
Here's the code:

Code:
SessionFactory sessionFactory = HibernateFactory.createFactory();
session = sessionFactory.openSession();
         
Query query = session.createQuery("from vo.Mp as mp where mp.referencia like upper(':ref_padrao')");
query.setParameter("ref_padrao", "%" + ref_padrao + "%");
List res = query.list();
( ... )


It gives me the following error:
Code:
net.sf.hibernate.QueryException: Named parameter does not appear in Query: ref_padrao [from vo.Mp as mp where mp.referencia like ':ref_padrao']
   at net.sf.hibernate.hql.QueryTranslator.getNamedParameterLocs(QueryTranslator.java:436)
   at net.sf.hibernate.hql.QueryTranslator.bindNamedParameters(QueryTranslator.java:817)
( ... )


Strange error (I think) because the parameter ref_padrao exists in the query.

Please help.

PS: why isn't the upper() function not appearing in the exception stack!?


Top
 Profile  
 
 Post subject: Re: Problems with Query interface
PostPosted: Tue Jan 20, 2004 10:31 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
nerotnt wrote:
I'm using Hibernate 2.1.1.
I'm trying to use the Query interface to obtain information.
Here's the code:
( ... )


I found the problem!
It should be upper(:ref_padrao) and not upper(':ref_padrao').
Thanks anyway.


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.