mysql – 如何使用Ebean createSqlQuery在列表中选择
作者:互联网
我正在用Ebean构建一个Play2应用程序.我创建了一个服务类,其中包含一个通过id列表获取场地的方法:
public static List<Venue> getVenuesForIds(List<Long> list){
ArrayList<Venue> venues = new ArrayList<Venue>();
String sql = "select c.id, c.name from Company c where in (:ids)";
List<SqlRow> sqlRows =
Ebean.createSqlQuery(sql).setParameter("ids", list).findList();
for(SqlRow row : sqlRows) {
venues.add(new Venue(row.getLong("id"), row.getString("name")));
}
return venues;
}
但是我得到了:
[PersistenceException: Query threw SQLException:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'in (201639091,201637666)' at line 1 Query was: select c.id, c.name from Company c where in (?,?) ]
我已阅读了http://www.avaje.org/ebean/introquery.html,但可能错过了正确的语法.我想在原始sql中执行此操作.
我错过了什么?
解决方法:
您的请求似乎不正确.
关于什么 :
"select c.id, c.name from Company c where c.id in (:ids)";
标签:mysql,playframework-2-0,ebean 来源: https://codeday.me/bug/20190517/1123661.html