org.hibernate.hql.ast.QuerySyntaxException:unexpected token错误public Aadmin quaryUserNames(String name) {String sql = "select * from Eadmin a where a.Aname = ";Query query = sessionFactory.getCurrentSession().createQuery(sql);query.setString(0,nam

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 06:58:28
org.hibernate.hql.ast.QuerySyntaxException:unexpected token错误public Aadmin quaryUserNames(String name) {String sql =
xSAkA+M I 'j$&gb9HmRh($N6_vx60}sxI/[EJU[B[z$mLpuAS6S`]h[&HգPO+ +E<_Vj,!F2FpB6yJz~1mbyqf!P]jJ;d!ih)䀏4\ڈgu2QL#Q՟\M#݈ij ,_DK1 /@xԖ`N:q|rkĶ[iӱ #ɣKĂf0|5;2=z&DIO?~W{}"lԻ= o瓶éi| O?G8?U`V##c|Ua$8E?z31i6~YuF~KgǼEgLvF wÎvқ [{g I0nR[$'Syg

org.hibernate.hql.ast.QuerySyntaxException:unexpected token错误public Aadmin quaryUserNames(String name) {String sql = "select * from Eadmin a where a.Aname = ";Query query = sessionFactory.getCurrentSession().createQuery(sql);query.setString(0,nam
org.hibernate.hql.ast.QuerySyntaxException:unexpected token错误
public Aadmin quaryUserNames(String name) {
String sql = "select * from Eadmin a where a.Aname = ";
Query query = sessionFactory.getCurrentSession().createQuery(sql);
query.setString(0,name);
Aadmin a = (Aadmin)query.uniqueResult();
return a;
}
提示错误:org.hibernate.hql.ast.QuerySyntaxException:unexpected token:* near line 1,column 8 [select * from Eadmin a where a.Aname = ]
但上面的sql语句直接拿到数据库(oracle)中是对的,问怎么改

org.hibernate.hql.ast.QuerySyntaxException:unexpected token错误public Aadmin quaryUserNames(String name) {String sql = "select * from Eadmin a where a.Aname = ";Query query = sessionFactory.getCurrentSession().createQuery(sql);query.setString(0,nam
String sql = "select * from Eadmin a where a.Aname = ";
Query query = sessionFactory.getCurrentSession().createQuery(sql);
query.setString(0,name);
sql = "select * from Eadmin a where a.Aname = "; 你这句话是标准的sql语句,但是你在这里sessionFactory.getCurrentSession().createQuery(sql);开启的是hibernate的面向对象的语句所以不可以,你改成sessionFactory.getCurrentSession().createSQL(sql);就可以了