<br>   Allen,<br><br>   I am not sure what is happening, because the correct way is to call a modify/update on $sm:<br><br>when<br><div><font size="2" face="Courier New, monospace">    $sat : Satellite(isOverhead == true)</font></div>

<div><font size="2" face="Courier New, monospace">    $sm : SatManager($ls : listOfOverheadSats not contains $sat)</font></div>
<div><font size="2" face="Courier New, monospace">then</font></div>
<div><font size="2" face="Courier New, monospace">    $ls.add($sat);<br>    update( $sm );<br>end<br><br>   This should not loop because of the condition itself, since now the &quot;not contains&quot; condition will be false and will prevent the loop.<br>
<br>   Can you double check there isn&#39;t another rule that is causing the loop? Otherwise, please open a JIRA.<br><br>   Regarding the question, drools manages collections as attributes in the same way it manages any other kind of &quot;Object&quot; attribute. Although, in drools 4, shadow facts do a shallow copy on collection attributes that sometimes require some care when working with evals(). But this is not your case.<br>
<br>    []s<br>    Edson<br>  <br></font></div>
<br><br><div class="gmail_quote">2009/4/20 Bagwell, Allen F <span dir="ltr">&lt;<a href="mailto:afbagwe@sandia.gov">afbagwe@sandia.gov</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>
<font size="3" face="Arial, sans-serif">
<div> </div>
<div><font size="2">This is in Drools 4.0.7</font></div>
<div><font size="2"> </font></div>
<div><font size="2">I have a class called SatManager with a field:</font></div>
<div><font size="2"> </font></div>
<div><font size="2" face="Courier New, monospace">ArrayList&lt;Satellite&gt; listOfOverheadSats </font></div>
<div><font size="2" face="Courier New, monospace"> </font></div>
<div><font size="2">That has an appropriate getter method.</font></div>
<div><font size="2"> </font></div>
<div><font size="2">I have a relatively simple rule that goes something like this:</font></div>
<div><font size="2"> </font></div>
<div><font size="2" face="Courier New, monospace">when</font></div>
<div><font size="2" face="Courier New, monospace">    $sat : Satellite(isOverhead == true)</font></div>
<div><font size="2" face="Courier New, monospace">    $sm : SatManager($ls : listOfOverheadSats not contains $sat)</font></div>
<div><font size="2" face="Courier New, monospace">then</font></div>
<div><font size="2" face="Courier New, monospace">    $ls.add($sat);</font></div>
<div><font size="2" face="Courier New, monospace"> </font></div>
<div><font size="2">My problem is that Drools doesn&#39;t understand that the ArrayList has been modified, therefore this rule always fires on the same satellite if the sat object changes in any other way.</font></div>
<div><font size="2"> </font></div>
<div><font size="2">I&#39;ve tried adding:</font></div>
<div><font size="2"> </font></div>
<div><font size="2" face="Courier New, monospace">update($sm);</font></div>
<div><font size="2" face="Courier New, monospace"> </font></div>
<div><font size="2">To the consequence, but that only caused the rule to re-fire infinitely -- even with the no-loop keyword applied.</font></div>
<div><font size="2"> </font></div>
<div><font size="2">So my question is how does Drools manage its knowledge of changes to Collections embedded in fact objects? The documention for the &#39;contains/not contains&#39; keyword did not explain this.</font></div>

<div><font size="2"> </font></div>
<div><font size="2">I&#39;m really stumped here.</font></div>
<div><font size="2"> </font></div>
<div><font color="#008080" size="2" face="Tahoma, sans-serif">Allen F. Bagwell</font></div>
<div><font color="#008080" size="1" face="Tahoma, sans-serif">e-mail:  <a href="mailto:afbagwe@sandia.gov" target="_blank">afbagwe@sandia.gov</a></font></div>
<div><font color="#008080" size="1" face="Tahoma, sans-serif">phone:  505/284-4517</font></div>
<div><font color="#008080" size="1" face="Tahoma, sans-serif">fax:  505/ 844-7886</font></div>
<div><font color="#008080" size="1" face="Tahoma, sans-serif"> </font></div>
<div style="margin-top: 5pt; margin-bottom: 5pt;"><font color="#008080" size="1" face="Tahoma, sans-serif">Ask your doctor if medical advice from a TV commercial is right for you.</font></div>
<div><font size="1" face="Tahoma, sans-serif"> </font></div>
<div><font size="2"> </font></div>
</font>
</div>

<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, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>