Error org. hibernate. hibernateexception: ordinal parameter mismatch.
My error is that the placeholder for setting parameters in the hql statement is not removed (the rough stream is down --///)
1 Hql + = "and BBs. ID = ? "+ BBS. ID;
Another error found on the Internet before is worth noting: the keyword "call" is used as the data field in the data table, so this problem occurs. Hibernate reports the following error:
Org. hibernate. hibernateexception: ordinal parameter Mismatch
At org. hibernate. Engine. query. hqlqueryplan. buildparametermetadata (hqlqueryplan. Java: 225)
At org. hibernate. Engine. query. hqlqueryplan. <init> (hqlqueryplan. Java: 95)
At org. hibernate. Engine. query. hqlqueryplan. <init> (hqlqueryplan. Java: 54)
At org. hibernate. Engine. query. queryplancache. gethqlqueryplan (queryplancache. Java: 71)
At org. hibernate. impl. abstractsessionimpl. gethqlqueryplan (abstractsessionimpl. Java: 133)
At org. hibernate. impl. abstractsessionimpl. createquery (abstractsessionimpl. Java: 112)
At org. hibernate. impl. sessionimpl. createquery (sessionimpl. Java: 1583)
......
The error is caused by the following section in the org. hibernate. Engine. query. parameterparser class:Code
1 Public Static Void Parse (string sqlstring, recognizer) Throws Queryexception {
2 Boolean Hasmainoutputparameter = sqlstring. indexof ("call")> 0 &&
3 Sqlstring. indexof ("? ") <Sqlstring. indexof (" call ")&&
4 Sqlstring. indexof ("=") <sqlstring. indexof ("call ");
5 ......
6 }
We all know that hibernate3 can call stored procedures or functions, but there are some restrictions (For details, refer to the official hibernate Manual ).
According to my analysis, this code is used to analyze whether a string is a statement that calls a stored procedure or function.
Solution:
1. Do not enter "call" in a table or column
2. Use criteria to replace hql statements