1
규칙을 작성하고 '또는'자매 클래스를 쓰려고 할 때 약간의 문제가 있습니다. 약간의 배경, 이것은 모두 실물 모형입니다. 6.4에 나와 있습니다. 나는 두 딸 가진 부모 클래스 사실이 있습니다 ChildAFact 및 ChildBFact을하고 나는이 규칙이 : 내 테스트를 실행하면자매 클래스에 '또는'을 사용하면 Drools 오류가 발생합니다.
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