Hi,<br>This doesn't seem to be a bug, IMHO, since no-loop is supposed (according to the doc). In this case, factA is called once (thanks to "no-loop", than fact2 is called once, and so on. Do you mean no-loop should still be on if it has been used once for a given rule?
<br><br>Chris<br><br><div><span class="gmail_quote">2007/7/3, Felipe Piccolini <<a href="mailto:felipe.piccolini@bluesoft.cl">felipe.piccolini@bluesoft.cl</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div style="margin: 0px;">I know I already asked this in a previous email, but no answer and diferent subject... so I'll ask again </div><div style="margin: 0px;"><br></div><div style="margin: 0px;">I have an issue using update in 2 rules that update the same object... a loop is created even when I try to
</div><div style="margin: 0px;">avoid the loop adding an extra condition to each rule... Im inserting an ArrayList as a fact too, so I can check</div><div style="margin: 0px;">the extra condition...</div><div style="margin: 0px;">
<br></div><div style="margin: 0px;">Can anyone tell me how to fix this?</div><div style="margin: 0px;"><br></div><div style="margin: 0px;">Consider this:</div><div style="margin: 0px;">//-------RULES-----------------------------
</div><div style="margin: 0px;"><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">package</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> cl.bluesoft.test</span></font></div>
<div style="margin: 0px; min-height: 15px;"><br></div><div style="margin: 0px;"><font color="#817e21" face="Monaco" size="3"><span style="font-size: 11px;">#list any import classes here.</span></font></div><div style="margin: 0px;">
<font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">import</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> java.util.List</span></font></div><div style="margin: 0px;"><font color="#821313" face="Monaco" size="3">
<span style="font-size: 11px;">import</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> java.util.ArrayList</span></font></div><div style="margin: 0px; min-height: 15px;"><br></div><div style="margin: 0px;">
<font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">import</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> cl.bluesoft.test.rules.Fact</span></font></div><div style="margin: 0px; min-height: 15px;">
<br></div><div style="margin: 0px;"><font color="#817e21" face="Monaco" size="3"><span style="font-size: 11px;">#declare any global variables here</span></font></div><div style="margin: 0px; min-height: 15px;"><br></div><div style="margin: 0px;">
<font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">rule</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> </span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">
"test update A"</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;"> </span></font><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">
salience</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> 699</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;"> </span></font><font color="#821313" face="Monaco" size="3">
<span style="font-size: 11px;">no-loop</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> </span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><font color="#821313" face="Monaco" size="3">
<span style="font-size: 11px;">when</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3"><span style="font-size: 11px;">
$f : Fact($n: number > 0)</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3"><span style="font-size: 11px;">$list: ArrayList( this
</span></font><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">excludes</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> </span></font><font color="#3a7c1c" face="Monaco" size="3">
<span style="font-size: 11px;">"key1"</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">)</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><font color="#821313" face="Monaco" size="3">
<span style="font-size: 11px;">then</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3"><span style="font-size: 11px;">
System.out.println(</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">"A-fact number1:"</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">+$f.getNumber()+
</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">" list 1:"</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">+$list);</span></font></div><div style="margin: 0px;">
<span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3"><span style="font-size: 11px;">$list.add(</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">
"key1"</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">);</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3">
<span style="font-size: 11px;">$f.setNumber($n + 1);</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font color="#821313" face="Monaco" size="3">
<span style="font-size: 11px;">update</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> ($f);</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">
        </span><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">update</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> ($list);</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">
        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3"><span style="font-size: 11px;">System.out.println(</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">"A-fact number2:"
</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">+$f.getNumber()+</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">" list 2:"</span></font><font face="Monaco" size="3">
<span style="font-size: 11px;">+$list);</span></font></div><div style="margin: 0px;"><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">end</span></font></div><div style="margin: 0px; min-height: 15px;">
<br></div><div style="margin: 0px; min-height: 15px;"><br></div><div style="margin: 0px;"><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">rule</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">
</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">"test update B"</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">
</span></font><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">salience</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> 699</span></font></div><div style="margin: 0px;">
<font face="Monaco" size="3"><span style="font-size: 11px;"> </span></font><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">no-loop</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">
</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">when</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">
        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3"><span style="font-size: 11px;">$f : Fact($n: number > 1)</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span>
<span style="white-space: pre;">        </span><font face="Monaco" size="3"><span style="font-size: 11px;">$list: ArrayList( this </span></font><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">excludes
</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> </span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">"key2"</span></font><font face="Monaco" size="3">
<span style="font-size: 11px;">)</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">then</span></font></div><div style="margin: 0px;">
<span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3"><span style="font-size: 11px;">System.out.println(</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">
"B-fact number1:"</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">+$f.getNumber()+</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">" list 1:"
</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">+$list);</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3">
<span style="font-size: 11px;">$list.add(</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">"key2"</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">
);</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3"><span style="font-size: 11px;">$f.setNumber($n + 1);</span></font>
</div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">update</span></font><font face="Monaco" size="3">
<span style="font-size: 11px;"> ($f);</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">
update</span></font><font face="Monaco" size="3"><span style="font-size: 11px;"> ($list);</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><font face="Monaco" size="3">
<span style="font-size: 11px;">System.out.println(</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">"B-fact number2:"</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">
+$f.getNumber()+</span></font><font color="#3a7c1c" face="Monaco" size="3"><span style="font-size: 11px;">" list 2:"</span></font><font face="Monaco" size="3"><span style="font-size: 11px;">+$list);</span></font>
</div><div style="margin: 0px;"><font color="#821313" face="Monaco" size="3"><span style="font-size: 11px;">end</span></font></div><div style="margin: 0px; min-height: 15px;"><font color="#821313"><br></font></div><div style="margin: 0px;">
//-------FACT-----------------------------</div><div style="margin: 0px;">public class Fact implements Serializable {</div><div style="margin: 0px;"><span style="white-space: pre;">        </span>private static final long serialVersionUID = 331627137981862975L;
</div><div style="margin: 0px; min-height: 14px;"><span style="white-space: pre;">        </span><br></div><div style="margin: 0px;"><span style="white-space: pre;">        </span>private int number;</div><div style="margin: 0px; min-height: 14px;">
<span style="white-space: pre;">        </span><br></div><div style="margin: 0px;"><span style="white-space: pre;">        </span>public Fact(int number){</div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">
        </span>this.number<span style="white-space: pre;">        </span>= number;</div><div style="margin: 0px;"><span style="white-space: pre;">        </span>}</div><div style="margin: 0px; min-height: 14px;"><span style="white-space: pre;">
        </span><br></div><div style="margin: 0px;"><span style="white-space: pre;">        </span>public Fact(){</div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span>this(0);</div>
<div style="margin: 0px;"><span style="white-space: pre;">        </span>}</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;"><span style="white-space: pre;">        </span>/**</div><div style="margin: 0px;">
<span style="white-space: pre;">        </span> * @return the number</div><div style="margin: 0px;"><span style="white-space: pre;">        </span> */</div><div style="margin: 0px;"><span style="white-space: pre;">        </span>public int getNumber() {
</div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span>return number;</div><div style="margin: 0px;"><span style="white-space: pre;">        </span>}</div><div style="margin: 0px; min-height: 14px;">
<br></div><div style="margin: 0px;"><span style="white-space: pre;">        </span>/**</div><div style="margin: 0px;"><span style="white-space: pre;">        </span> * @param number the number to set</div><div style="margin: 0px;"><span style="white-space: pre;">
        </span> */</div><div style="margin: 0px;"><span style="white-space: pre;">        </span>public void setNumber(int number) {</div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">
        </span>this.number = number;</div><div style="margin: 0px;"><span style="white-space: pre;">        </span>}</div><div style="margin: 0px; min-height: 14px;"><span style="white-space: pre;">        </span><br></div><div style="margin: 0px;">
}</div><div style="margin: 0px; min-height: 15px;"><font color="#821313"><br></font></div><div style="margin: 0px;">//------TEST---------</div><div style="margin: 0px;">public class TestUpdateFact implements Serializable {
</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;"><span style="white-space: pre;">        </span>private static final long serialVersionUID = -574789596641083743L;</div><div style="margin: 0px; min-height: 14px;">
<br></div><div style="margin: 0px;"><span style="white-space: pre;">        </span>/**</div><div style="margin: 0px;"><span style="white-space: pre;">        </span> * @param args</div><div style="margin: 0px;"><span style="white-space: pre;">
        </span> */</div><div style="margin: 0px;"><span style="white-space: pre;">        </span>public static void main(String[] args) {</div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">
        </span><font face="Monaco" size="3"><span style="font-size: 11px;">RuleBase ruleBase = RuleBaseFactory.newRuleBase();</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">
        </span><font face="Monaco" size="3"><span style="font-size: 11px;">Package pkg = builder.getPackage();</span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">
        </span><font face="Monaco" size="3"><span style="font-size: 11px;">.... </span></font></div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span>WorkingMemory session =
ruleBase.getStatefulSession();</div><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span>...etc etc...</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;">
<span style="white-space: pre;">        </span><span style="white-space: pre;">        </span>List list = new ArrayList();</div><p style="margin: 0px; min-height: 14px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">
        </span><br></p><div style="margin: 0px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span>Fact fact1 = new Fact(1);</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;">
<span style="white-space: pre;">        </span><span style="white-space: pre;">        </span>session.fireAllRules();</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;"><span style="white-space: pre;">
        </span><span style="white-space: pre;">        </span>....etc, etc...</div><p style="margin: 0px; min-height: 14px;"><span style="white-space: pre;">        </span><span style="white-space: pre;">        </span><br></p><div style="margin: 0px;">
<span style="white-space: pre;">        </span>}</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;">}</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;">//--------OUTPUT------------
</div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">A-fact number1:1 list 1:[]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">
A-fact number2:2 list 2:[key1]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">B-fact number1:2 list 1:[key1]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3">
<span style="font-size: 11px;">B-fact number2:3 list 2:[key1, key2]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">A-fact number1:3 list 1:[key1, key2]</span></font>
</div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">A-fact number2:4 list 2:[key1, key2, key1]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">
B-fact number1:4 list 1:[key1, key2, key1]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">B-fact number2:5 list 2:[key1, key2, key1, key2]</span></font></div><div style="margin: 0px;">
<font face="Monaco" size="3"><span style="font-size: 11px;">A-fact number1:5 list 1:[key1, key2, key1, key2]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">A-fact number2:6 list 2:[key1, key2, key1, key2, key1]
</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">B-fact number1:6 list 1:[key1, key2, key1, key2, key1]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3">
<span style="font-size: 11px;">B-fact number2:7 list 2:[key1, key2, key1, key2, key1, key2]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">A-fact number1:7 list 1:[key1, key2, key1, key2, key1, key2]
</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">A-fact number2:8 list 2:[key1, key2, key1, key2, key1, key2, key1]</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3">
<span style="font-size: 11px;">B-fact number1:8 list 1:[key1, key2, key1, key2, key1, key2, key1]</span></font></div><div style="margin: 0px; min-height: 15px;"><br></div><div style="margin: 0px;"><font face="Monaco" size="3">
<span style="font-size: 11px;">.... for ever.....</span></font></div><div style="margin: 0px; min-height: 15px;"><br></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">So I have a loop... only when I use update and both rules... condition about the
</span></font></div><div style="margin: 0px;"><font face="Monaco" size="3"><span style="font-size: 11px;">list not containing "key1" and "key2" seems not properly chequed... I dont know...</span></font>
</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;">Can somebody help me? Am I missing something here?</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;">
Thanks.</div><br><div> <span style="border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<div><span style="text-decoration: underline;"><span> </span></span><div><font size="3"><span style="font-size: 13px;"><b style="font-size: 13px; font-weight: bold;">
<span style="font-size: 13px; font-weight: bold;">Felipe Piccolini M.</span></b></span></font></div><div><a href="mailto:felipe.piccolini@bluesoft.cl" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
<span style="color: rgb(0, 0, 238);">felipe.piccolini@bluesoft.cl</span></a></div><br></div><div><br></div><br></span> </div><br></div><br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">
rules-users@lists.jboss.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" 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>