[rules-users] Question about Drools accessing a global HashMap and comparing it to an object value

mviens mike at viens.com
Thu Jan 27 16:15:38 EST 2011


Hi Greg,

Thank you for the reply.  I converted the rules back to being processed in
singular mode versus through an ArrayList as you recommended.  I am curious
about the reason though -- is it a performance issue or does it just make it
more difficult to work with within the rule?

I tried your recommendation of the rule, but it caused an error:

rule "Check for valid code"
    when
        obj : MyObj(objState : state, objCode : code)
        codes : State2Code(state == objState && objCode not memberOf codes)
    then
        obj.addError("Code is not valid for the State");
end

BuildError: Unable to create Field Extractor for 'objCode' of
'[ClassObjectType class=com.abc.xyz.StateFips]' in rule 'Check for valid
Code'


When I changed the rule to this, the error is gone and it worked just fine.

rule "Check for valid code"
    when
        obj : MyObj(objState : state, objCode : code)
        codes : State2Code(state == objState && codes not contains objCode)
    then
        obj.addError("Code is not valid for the State");
end

Do you have any thoughts on why the first rule does not work but the second
one does?  Is it a bug?  The only difference between the rule I have and the
one you suggested was using a comma versus ==.  I tried with the comma, but
the error remained.  I am using Drools 5.1.1.

Mike V.
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-Drools-accessing-a-global-HashMap-and-comparing-it-to-an-object-value-tp2334346p2364040.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list