Post an exception first
Struts has detected an unhandled exception:Messages:Position beyond number of declared ordinal parameters. Remember that ordinal parameters is 1-based! Position:1file:org/hibernate/engine/query/spi/parametermetadata.java Stacktracesorg.hibernate.QueryParameterException:Position beyond number of declared ordinal parameters. Remember that ordinal parameters is 1-based! Position:1
Code:
Define HQL
String hql = "from book book where" + "Book.booktype Like:queryargs or" + "book. Booknum Like:queryargs or" + "Book.book Name Like:queryargs or "+" Book.bookauthor Like:queryargs "+" ORDER by Book.booktype, book. Booknum, Book.bookauthor, bo Ok.bookname ";//dao set value in query query = Sessionfactory.getcurrentsession (). CreateQuery (HQL); for (int i = 0; i < Objects.length; i++) {Query.setparameter (I, objects[i]);}
Reason:
The exception is that the placeholder index is out of bounds (overflow) because there is no placeholder "?" in my defined hql, I use a named parameter that should be passed setstring (paraname,paravalue) or Setparameter (Paraname, Paravalue) way to set the value, but I use Setparameter (int arg0, Object arg1) to set the value, so the error!
Workaround:
For me this, I pass: Queryargs all replaced? The way.
A placeholder in the Hibernate query statement hql? parameter and named parameter: Name set Value method to confuse