1
私は、ルールを書いているときや姉妹クラスをやっているときに、私は少し問題があります。いくつかの背景、これはすべて実証する小さなモックアップです、これは6.4です。私は2人の娘を持つ親クラスの事実があります。ChildAFactとChildBFactを、私はこのルールを持っている:姉妹クラスで「または」を使用するとエラーが発生する
rule "Rule 1"
when
f: (ChildAFact() or ChildBFact())
then
System.out.println(f);
end
私は私のテストを実行すると、私はこのエラーを取得:
java.lang.RuntimeException: Error while creating KieBase[Message [id=1, level=ERROR, path=Sample.drl, line=12, column=0
text=Duplicate declaration for variable 'f' in the rule 'Rule 1'], Message [id=2, level=ERROR, path=Sample.drl, line=10, column=0
text=Unable to Analyse Expression System.out.println(f);:
[Error: unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.f()]
[Near : {... System.out.println(f); ....}]
^
[Line: 10, Column: 0]]]
at org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:450)
at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:604)
at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:575)
at com.sample.DroolsTest.main(DroolsTest.java:20)
私は誰かが知っていた期待していましたこれを修正する方法。条件に合致するオブジェクトが「偽」されているオブジェクトの最も近い共通の祖先にキャストされることを望んでいました。
ああ、複数のタイプをバインドできないことを知っておきたい。それは残念ですが、私はそれを回避する必要があります。私が最初にこれをやりたかった理由は、すべてのファクトオブジェクトを見る必要がなく、タイプに基づいて異なる基準を満たすファクトの子のみでした。 – Hangman4358