Hibernate resolve the sql statement appears Legacy-style query parameters ( `?`) Problem

In this version of hibernate-release-5.4.10.Final, make this SQL statement to operate,

String hql = "from Customer where cust_name like ?";

Compiler implementation will be

Legacy-style query parameters (`?`) are no longer supported; use JPA-style ordinal parameters (e.g., `?1`) instead : from com.itheima.hibernate.demo1.Customer where cust_name like ? [from com.itheima.hibernate.demo1.Customer where cust_name like ?]

This situation only String hql = "from Customer where cust_name like 0?"; In ? Followed by the index you paired with, and my statement is executed query.setParameter ( 0 , "Wang%"); This We can solve these problems.

 

Published 12 original articles · won praise 0 · Views 276

Guess you like

Origin blog.csdn.net/weixin_45488363/article/details/104997420