Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: James Rivera   on Mar 22 In Java Category.

  
Question Answered By: Angel Watkins   on Mar 22

"No value specified for parameter 1" means the first parameter that you have considered in your query, does not have any value assigned to it.

Look at the following sample :

Query query=getSession().createQuery("from A a left outer join a.B b where b.x< :something");

return query.list();



look at the parameter "something" in the query. The code above will throw the same exception that you received because this line is missing before query.list():

query.setParameter("something", 10);



If I were you, I would use HQL for such a long where clause along with a WildCardHelper for Strings. I mean there are times that you need to add such clauses to your criteria  :

where b.x like "%" + something or

where b.x like something + "%" or

where b.x like "%" + something + "%"



I always let users to use a wildcard like * on the search  fields. and then I analyse the user entry and turn it to the above examples using a helper class(e.g. em* will result in "emil", "emily", ....) . There are also cases where you want to search something among a string where you can automatically load it with MatchMode Anywhere( "%" + something + "%"). Anyway In my opinion HQL is much easier when you have a search page  with multiple items to search. First left outer join the entities that you are to search your information upon and then add the user input on the where clause....

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Hibernate Criteria question Or get search suggestion and latest updates.


Tagged: