-->
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: Problem when I use parameters into HQL
PostPosted: Mon Mar 14, 2011 12:01 pm 
Newbie

Joined: Wed Jan 19, 2011 6:25 am
Posts: 2
I am trying to use this query:

Code:
   //Recupero la sessione da Hibernate
      Session session = sessionFactory.getCurrentSession();
      logger.debug("Il nome della licenza e': "+nomelicenza);
      String textQuery = "from Vocelicenza as v where v.voceLicenza = :nomelicenza";
      Query query = session.createQuery(textQuery);
      List<Vocelicenza> listaVocLic = query.list();
      int lastIndex = listaVocLic.size()-1;
      return listaVocLic.get(lastIndex);
      


where nomelicenza is a String, but when I run my Spring MVC application I obtain the following error:
Not all named parameters have been set: [nomeLicenza] [from Vocelicenza as v where v.voceLicenza = :nomeLicenza]


Top
 Profile  
 
 Post subject: Re: Problem when I use parameters into HQL
PostPosted: Mon Mar 14, 2011 1:26 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
You'll need to set the value of the parameter before executing the query.list() method:

Code:
query.setString("nomelicenza", valueOfParameter);


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.