hibernate 执行hql,操作的是表映射的类,不是表。
"select usr from my_test usr where name = ?"
改为 "from User where username=?"
应该使用HQL作为查询语言,而不是传统的SQL了,HQL是面向对象的,所以需要使用User对象代替表名。
所以HQL应该这样写:
select usr from User usr where usr.name = ?
你这个sql语句,我不知道有什么问题没有?
select usr from my_test usr where name = ?
这是什么意思?where “ name = ?”如果传的参数是name的话,为什么上面给的是id?|
你要查询的是表中的一条记录还是一个字段?
希望我这些问题,能帮你找到答案。
没错,得用HQL的语法
SELECT user FROM User user WHERE user.namt=?
select usr from my_test usr where name = ?
改成
from User user where user.id= ? ;