• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

named paramneter not set error

 
vineet varghese
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello the following is my hibernate function....i am passing a string variable as parameter to it but while using cusid in the from clause i am getting the eror

but if i hard code the value as 5 i am getting the correct output.
can someone correct me please ?
thank you
 
Komal Renu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you paste the original query, the one where you pass custId. also please give the error trace.

Thanks and Regards,
-------------------------------------------------------------------------------------
Komal Renu | krenu@infocepts.com | www.infocepts.com
-------------------------------------------------------------------------------------
 
Waswani Naresh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please let us know how did you configure name parameter and how are you passing value to it ?

Regards,
Naresh Waswani
 
vineet varghese
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am calling the function in the following way



//if i pass a constant value it dosent show any error but on passing the variable cid it gives the following eror







 
Waswani Naresh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably I got the error.

In the method getAll_bill_by_cid(String cusid), you are receiving the value in the cusid and I believe your named parameter is set to cusid.

The only thing you are missing is setting the value for the named parameter. Just call below method on the query object

setString("cusid",value);

and then call list() on it.


Regards,
Naresh Waswani
 
vineet varghese
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nope it gives a translation error
i am getting the parameter in my function but the query is giving the problem
 
Waswani Naresh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the original query code where you are using parameter name.

Regards,
Naresh Waswani
 
vineet varghese
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have posted it above.....userlink is a list variable
and on using the constant value "5" i get the list but not on replacing it with "cusid"
 
Waswani Naresh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just by replacing it with cusid wil not help.

As I mentioned before, you need to set the value of cusid before you call the list() method on it. If you have ever used parameter place holder (?) used with PreparedStatement of JDBC, named parameter are exactly the same.

Please take a look at PreparedStatement usage with paremeter place holders using "?".

Regards,
Naresh Waswani
 
Waswani Naresh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While setting the value also make sure that the cusid in Database is string or integer.

Regards,
Naresh Waswani
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic