Org. hibernate. hibernateexception: ordinal parameter Mismatch

Source: Internet
Author: User
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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.