在执行查询期间,我收到错误Expected positional parameter count: 1, actual parameters: []
我的查询没有任何参数,但是查询包含?作为值。
码
session.createSQLQuery(sql).list()
SQL
SELECT file.name as `NAME` FROM film WHERE film.name IN ('You say "How I can make it? We' ..."');
修改
如果按名称搜索包含?和'
,它也会重现SELECT file.name as `NAME` FROM film WHERE film.name IN ('?'')
我该如何解决?
感谢。
答案 0 :(得分:1)
应该工作
String[] values= {"You say \"How I can make it? We' ...\""};
String sql = "SELECT file.name as `NAME` FROM film WHERE film.name IN (:values)";
SQLQuery query = session.createSQLQuery(sql);
query.setParameterList("values", values);
然后
query.list();