IConditionTree表現をCriterionに変換する必要があります。
現在、論理演算子ANDとORを実装していますが、NOTも追加する必要があります。ただし、このタイプの基準はジャンクションとして表されないため、Restrictions.not(基準基準)を使用して作成する必要があります。条件ツリーの処理中に、入力パラメーターとして挿入する必要がある次の基準がわかりません。
//initial call
criteria.add(generateNodeCriteria(conditionTree.getRoot(), conditionTree));
private Criterion generateNodeCriteria(IConditionTreeNode node, IConditionTree conditionTree) throws SomeException {
// Create criteria for condition
if (node.getCondition() != null) {
return createConditionCriterion(node.getCondition());
}
// Create criteria for logical operator
if (node.getLogicalOperator() != null) {
// What logical operator to use?
Junction junction = null;
switch (node.getLogicalOperator()) {
case AND:
junction = Restrictions.conjunction();
break;
case OR:
junction = Restrictions.disjunction();
break;
}
// Add all direct children of logical operator into conjunction
for (IConditionTreeNode childNode : conditionTree.getOneLevelChildren(node)) {
junction.add(generateNodeCriteria(childNode, conditionTree));
}
return junction;
}
throw new SomeException();
}
NOT論理演算子をスイッチ部分に実装する方法はありますか?AND / OR演算子と同じNOT論理演算子の動作が必要な場合はどうすればよいですか?