2つの異なるフィールドでORを実行することはできません。ドキュメントの抜粋は次のとおりです。
JDOQL文字列構文では、||を使用して複数のフィルターを区切ることができます。(論理"または")および&&(論理 "および")、ただし、|| 分離するフィルターがすべて同じフィールド名である場合にのみ使用できます。言い換えれば、|| 分離するフィルターを単一のcontains()フィルターに組み合わせることができる状況でのみ有効です。
// legal, all filters separated by || are on the same field
Query query = pm.newQuery(Employee.class,
"(lastName == 'Smith' || lastName == 'Jones')" +
" && firstName == 'Harold'");
// not legal, filters separated by || are on different fields
Query query = pm.newQuery(Employee.class,
"lastName == 'Smith' || firstName == 'Harold'");
これを回避する1つの方法は、aとbをリストに保存することです。fooというアイテムのリストがある場合は、foo =キーワードでクエリを実行できます。また、foo内のいずれかのアイテムが一致する場合は、そのオブジェクトが結果に返されます。あなたはaとbが何であるかについてあまり言わないので、これがあなたのために働くかどうかはわかりません:)
更新:
public class Example {
String firstName;
String lastName;
List<String> allNames;
public Example(String first, String last){
firstName = first;
lastName = last;
allNames = new ArrayList<String>();
allNames.add(first);
allNames.add(last);
}
}
そのようなもので、「allNames =='Smith' || allNames=='Jones'」というクエリを実行できます。