如何在Play中執行查詢!帶IN條件的框架?我已經按照此鏈接Play Framework - How to Query a Model using 'IN'?的解決方案,但我得到一個非法Arugment異常錯誤:使用IN條件播放框架查詢
IllegalArgumentException occured : org.hibernate.hql.ast.QuerySyntaxException: cannot define positional parameter after any named parameters have been defined [from models.Post where (category_id in (:cat)) AND (gender like ?) AND (name like ? OR description like ?) AND isComplete is ? order by created_date desc]
,這是我的代碼..
String arrString[] = category.split(",");
List<String> listString = new ArrayList<String>();
for(int i=0; i<arrString.length; i++) {
listString.add(arrString[i]);
}
posts = Post.find(
"(category_id in (: cat)) AND (gender like?) AND (name like? OR description like?) AND isComplete is? " +
"order by created_date desc", gender, search, search, true
).bind("cat", listString).from(0).fetch(50);
我不能簡單地使用(? )IN語法。所以它會是這樣的:
posts = Post.find(
"(category_id in (?)) AND (gender like?) AND (name like? OR description like?) AND isComplete is? " +
"order by created_date desc", category, gender, search, search, true
).from(0).fetch(50);
我在哪裏做錯了?任何意見,將不勝感激。