2011-09-16 7 views

答えて

7

あなたは

MyModel.find("status IN (:ids) ORDER BY createdAt").bind("ids", idExs).fetch(); 
を試してみました
1

(1, 5, 8)が一定であれば、それは非常に簡単です:

List<MyModel> r = MyModel.find("status in (1, 5, 8) order by createdAt").fetch(); 

それはパラメータである必要がある場合:

List<Integer> s = Arrays.asList(1, 5, 8); 
List<MyModel> r = MyModel.find("status in :s order by createdAt") 
    .bind("s", s).fetch(); 

ここで重要なポイントは、あなたがin句を使用することができるということですHibernateの制限のために、位置指定されたパラメータ(?)ではなく、指定されたパラメータのみです。

関連する問題