1
votes

When i use below condition with 'not' I am getting an error.

    not(Obj1(value == 0) && Obj2(value <= 3))

However if i replace above condition as below I am not getting any casting exception

    Obj1(value != 0) or Obj2(value > 3)

The rule looks like this:

rule "test_6"
salience 10
    when
         not(Obj1(value == 0) && Obj2(value <= 3))
    then
        .....
end

And this is the error I'm getting:

throwing error Error Message: org.drools.core.rule.GroupElement cannot be cast to org.drools.core.rule.Pattern
1

1 Answers

1
votes

The && and || operators can only be used inside a single pattern. For example: Obj1( value > 3 && value < 10 || value == 0). According to the documentation, to separate Patterns, you have to use the and and or operators.

So, in your case, your rule should be:

rule "test_6"
salience 10
    when
         not(Obj1(value == 0) and Obj2(value <= 3))
    then
        .....
end

Note that it was not failing when you were using or because that was the right operator to use instead of ||.

Hope it helps,