Hql 中实用查询时候 引号的使用

出错代码://List vlist = this.getHibernateTemplate().find("from AndroidCustomer ct where ct.token = "+token);

正确代码:List vlist= this.getHibernateTemplate().find("from AndroidCustomer a where a.token= '" + token+"'");

这里的token为字符串,(当为字符串或者日期时候一定要有单引号,因为在数据库查询的时候也要用到单引号)

当为数字时候,可以不用单引号,因为PL/SQL中查询的时候及没有用到单引号,数字。千万注意

原文地址:https://www.cnblogs.com/beijingstruggle/p/6202282.html