Inserting two equal objects results in two facts, and each will trigger a matching rule.

If your class Result contains a proper implementation of equals() and hashCode(), you
may use
   KnowledgeBaseConfiguration conf = ....
   conf.setOption( AssertBehaviorOption.IDENTITY );
   KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( conf );
and then inserting another equal object will be ignored by the engine.

You should not use
  not( exists(...) )
not() alone is the negated existence quantifier. Although not wrong,
it's generally considered to be inelegant and confusing.

-W

2010/11/8 J-C Walmetz <jc7442@yahoo.fr>
Hi

I use Drools 5.01

I have the following rules:
 
rule "Reload test" salience 10000

    when
        $result: Result( $resultId:resultId)
        not (exists Test(resultId.technicalId==$resultId.technicalId))
    then
        Test test = createTest($resultId);
         insert(test);
end

When I  insert two results with the same identifier, rules is applyed 2 times. One for each result. I do not understand why.

Do you have an idea of what's happen and how to guratantee that myl rules will not be applied twice. Here order is not important ...

Thanks


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users