首頁 >資料庫 >mysql教程 >hibernate使用select ifnull报错但是在mysql直接运行没问题

hibernate使用select ifnull报错但是在mysql直接运行没问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-06 09:35:171612瀏覽

mysqlselecthibernate

<code>    String sql = "select ifnull(pushtoken,0) from  user where id="+user.getId();    Session session = this.getHibernateTemplate().getSessionFactory()            .openSession();    Query q = session.createSQLQuery(sql);    List list = q.list();    查询的时候报错</code>

[10:40:59|INFO |(org.hibernate.type.StringType)]=[could not read column value from result set: ; Column '' not found.]
[10:40:59|WARN |(org.hibernate.util.JDBCExceptionReporter)]=[SQL Error: 0, SQLState: S0022]
[10:40:59|ERROR|(org.hibernate.util.JDBCExceptionReporter)]=[Column '' not found.]
org.hibernate.exception.SQLGrammarException: could not execute query

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn