hibernate使用selectifnull报错但是在mysql直接运行没问题
来源:懂视网
责编:小采
时间:2020-11-09 16:50:29
hibernate使用selectifnull报错但是在mysql直接运行没问题
hibernate使用selectifnull报错但是在mysql直接运行没问题:mysqlselecthibernate 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(
导读hibernate使用selectifnull报错但是在mysql直接运行没问题:mysqlselecthibernate 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(

mysqlselecthibernate
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(); 查询的时候报错
[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
hibernate使用selectifnull报错但是在mysql直接运行没问题
hibernate使用selectifnull报错但是在mysql直接运行没问题:mysqlselecthibernate 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(