It does short circuit on &quot;constraints&quot;. Not on patterns.<div><br></div><div>   The problem is your assumption that rules are executed in order. They are not. Check the manual for &quot;Conflict Resolution&quot;.</div>
<div><br></div><div>   Also, the LHS of rules are executed at &quot;insert&quot;/&quot;modify&quot; time, so the LHS of both rules will be executed before any of them is fired. </div><div><br></div><div>   The shortest syntax for your case is to use an mvel inline eval using the null-safe navigation:</div>
<div><br></div><div>rule X</div><div>    dialect &quot;mvel&quot;</div><div>when</div><div>    ...</div><div>   <span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "> CreditTransferTransactionInformation10( eval( !( accountNumbers contains dbtrAcct.?id.?othr.?id ) ) )</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">    ...</span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">   Of course, you can do all the null checks in the pattern itself, avoiding the need to use the mvel syntax. </span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">   Edson</span></font></div>
<div><br><div><br><div class="gmail_quote">2010/7/16 Meeraj Kunnumpurath <span dir="ltr">&lt;<a href="mailto:mkunnumpurath@googlemail.com">mkunnumpurath@googlemail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks Dave.<br><br>I think the &#39;||&#39; on rule 1 is getting short-circuited. However, it is the &#39;&amp;&amp;&#39; on rule 2 that is not getting short circuited.<br><br>Kind regards<br>Meeraj<br><br><div class="gmail_quote">

2010/7/16 David Sinclair <span dir="ltr">&lt;<a href="mailto:dsinclair@chariotsolutions.com" target="_blank">dsinclair@chariotsolutions.com</a>&gt;</span><div><div></div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">

Drools doesn&#39;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&#39;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">&lt;<a href="mailto:mkunnumpurath@googlemail.com" target="_blank">mkunnumpurath@googlemail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">

<div><div></div><div>
Hi,<br><br>I have the following rules,<br><br>global java.util.Set accountNumbers;<br><br>rule &quot;rule 1&quot;<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(&quot;PR002&quot;);<br>    $i.setAdditionalInfo(&quot;Account number is null&quot;);<br>end<br><br>rule &quot;rule 2&quot;<br>



when<br>    $d : Document()<br>    $c : CreditTransferTransactionInformation(internalInfo.status != PaymentStatus.INVALID &amp;&amp; <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(&quot;PR002&quot;);<br>    $i.setAdditionalInfo(&quot;Account number not available in the routing table&quot;);<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></div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></div></div><br>
<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><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div></div>