When I recently debugged a Web site with Eclipse, I found an old warning in the console:
WARN [org.hibernate.hql.internal.ast.hqlsqlwalker]–[deprecation] encountered positional parameter near line 1, column 9 5. Positional parameter is considered de precated; Use named parameters or Jpa-style positional parameters instead.
Search on the Internet to understand is the HQL statement in the query parameter placeholder use method obsolete.
It is recommended to replace the old placeholder Query method with either named parameters or JPA placeholders, and now compare the following:
Old:
HQL statement notation: string hql = "from user as u where U.username =?" (just use a hello placeholder)
Parameter settings: Query.setparameter (0, "Jason"), or query.setstring (0, "Jason"); (The first parameter is the position of the placeholder, int type)
New:
HQL statement notation: string hql = "from user as U where U.username =: Name" (colon + parameter name placeholder mode)
Parameter settings: Query.setparameter ("name", "Jason") (the first parameter is the parameter name, String type)
HQL statement notation: string hql = "from user as U where U.username =" (JPA placeholder, question mark + arbitrary digit placeholder)
Parameter settings: Query.setparameter ("Ten", "Jason") (the first parameter is a placeholder number, String type!!)
Use either of the latter two to make the warning disappear.
With the API, the framework of the update, many places will be changed, and even refactoring. But in general, it is to make the design more reasonable, controllable, reduce ambiguity.
So in the process of use sometimes have to pay extra attention to version changes. Continuous learning, continuous improvement, this is also a charm of programming, Ha, said much.