Drools doesn't use short circuit evaluation, so all of those ORs are going to be evaluated. You may want to consider re-writing your rules or you can use MVEL's null safe navigation for this. dbtrAcct.?id == null, dbtrAcct.?id.?othr == nulll, etc.<br>
<br>dave<br><br><br><br><div class="gmail_quote">2010/7/16 Meeraj Kunnumpurath <span dir="ltr"><<a href="mailto:mkunnumpurath@googlemail.com">mkunnumpurath@googlemail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I have the following rules,<br><br>global java.util.Set accountNumbers;<br><br>rule "rule 1"<br>when<br>    $d : Document()<br>    $c : CreditTransferTransactionInformation (dbtrAcct == null || dbtrAcct.id == null || dbtrAcct.id.othr == null || <a href="http://dbtrAcct.id.othr.id" target="_blank">dbtrAcct.id.othr.id</a> == null) from $d.cstmrCdtTrfInitn.cdtTrfTxInf<br>
    $i : InternalInfo() from $c.internalInfo<br>then<br>    $i.setStatus(PaymentStatus.INVALID);<br>    $i.setErrorCode("PR002");<br>    $i.setAdditionalInfo("Account number is null");<br>end<br><br>rule "rule 2"<br>
when<br>    $d : Document()<br>    $c : CreditTransferTransactionInformation(internalInfo.status != PaymentStatus.INVALID && <a href="http://dbtrAcct.id.othr.id" target="_blank">dbtrAcct.id.othr.id</a> not memberOf accountNumbers) from $d.cstmrCdtTrfInitn.cdtTrfTxInf<br>
    $i : InternalInfo() from $c.internalInfo<br>then<br>    $i.setStatus(PaymentStatus.INVALID);<br>    $i.setErrorCode("PR002");<br>    $i.setAdditionalInfo("Account number not available in the routing table");<br>
end<br><br>My assumption is rule 1 and rule 2 will be executed in the order they appear. Rule 1 checks all the nested attributes are not null and set the status as invalid if any of them is null. Rule 2 uses the and operator and checks the nested attribute is in the collection defined by the global, only if the object is valid. I assume the LHS of rule 2 will be short circuited if the object is invalid. However, if any of the nested property is null I get the following exception from MVEL.<br>
<br>Caused by: [Error: unable to access property (null parent): id]<br>[Near : {... Unknown ....}]<br>             ^<br>[Line: 1, Column: 0]<br>    at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:861)<br>
<br>Regards<br><font color="#888888">Meeraj<br>
</font><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>