StringBuilder hql = new StringBuilder("from Student where 1=1");
执行时相当于
SELECT * from t_student where 1=1 and stu_name LIKE ' %王% ';
正确写法:两边不能有空格
执行时相当于
SELECT * from t_student where 1=1 and stu_name LIKE ' %王% ';
本文介绍了一个使用StringBuilder构造HQL查询语句的例子,并指出在拼接SQL字符串时去除空格的重要性,以确保查询语句的正确性和效率。
StringBuilder hql = new StringBuilder("from Student where 1=1");
执行时相当于
SELECT * from t_student where 1=1 and stu_name LIKE ' %王% ';
正确写法:两边不能有空格
执行时相当于
SELECT * from t_student where 1=1 and stu_name LIKE ' %王% ';
2311

被折叠的 条评论
为什么被折叠?
