&nbsp;&nbsp; Przemyslaw,<br><br>&nbsp;&nbsp; There are no plans to change the behavior for 5.0. In 5.1 with a feature that we call &quot;true modify&quot; we may be able to improve the situation.<br><br>&nbsp;&nbsp; Let me explain it in a better way: the &quot;from&quot; expression is a black box for the engine. You can call *any* code in that expression and a common case is to use the expression to pull data from a database on-demand. Since it is a black box, the engine assumes that every time the expression is re-evaluated you are bringing new data into the engine and as so it creates new fact handles for it. A modify in most Rete engines is a retract+assert and it is like this in drools 4-5 too. So, when you modify the fact that is written before the &quot;from&quot; in LHS, it will retract all facts previously created by &quot;from&quot;, re-evaluate it, and create new fact handles for them.<br>
<br>&nbsp;&nbsp; Since no-loop and lock-on-active use the fact handles to determine when a fact is equals to another, you get this side effects.<br><br>&nbsp;&nbsp; A way to work around the problem is have your data in the working memory, reducing the usage of from. Another way to work around the problem is if you can write the patterns that use from before the patterns that are modified by your rules. E.g:<br>
<br>Rule X<br>when<br>&nbsp;&nbsp;&nbsp; $a : A()<br>&nbsp;&nbsp;&nbsp; $b : B() from somewhere<br>&nbsp;&nbsp;&nbsp; $c : C()<br>&nbsp;&nbsp;&nbsp; $d : D()<br>then<br>&nbsp;&nbsp;&nbsp; // ...<br>end<br><br>&nbsp;&nbsp; If $a is modified by any rule or by the application, the whole LHS of the above rule is re-evaluated. If $c is modified, only $c and $d are reevaluated, and so on. Placing the facts that you modify frequently &quot;after&quot; any pattern that uses &quot;from&quot; is a way to prevent this behavior. It is not always possible, I know, but it helps with this side-effect whenever possible.<br>
<br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><br><br><div class="gmail_quote">2009/2/13 Przemysław Różycki <span dir="ltr">&lt;<a href="mailto:P.Rozycki@amg.net.pl">P.Rozycki@amg.net.pl</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;">
Edson, Michal,<br>
<br>
thank you for your answers. If I understand well, Drools can&#39;t recognize if the $fact2 has been changed by the current rule or not.<br>
Anyway, I found such a behaviur as a bit confusing, so my second question is, is it a desirable behaviour? And is it going to be changed or left as is?<br>
<br>
Best regards<br>
Przemyslaw<br>
<br>
Edson Tirelli pisze:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
<br>
 &nbsp; &nbsp;Michal is correct. Every time a &quot;from&quot; expression is executed, Drools does not know if a result for the expression is new or not and it creates a new fact handle, bypassing the no-loop.<br>
<br>
 &nbsp; &nbsp;[]s<br>
 &nbsp; &nbsp;Edson<br>
<br></div>
2009/2/13 Michal Bali &lt;<a href="mailto:michalbali@gmail.com" target="_blank">michalbali@gmail.com</a> &lt;mailto:<a href="mailto:michalbali@gmail.com" target="_blank">michalbali@gmail.com</a>&gt;&gt;<div class="Ih2E3d">
<br>
<br>
 &nbsp; &nbsp;This is what I think is going on:<br>
 &nbsp; &nbsp;when you call update($fact1) it will first retract $fact1 which in<br>
 &nbsp; &nbsp;turn retracts $fact2, the $fact1 is then inserted again which cause<br>
 &nbsp; &nbsp;another &#39;from&#39; evaluation and a NEW $fact2 is pulled -&gt; no-loop<br>
 &nbsp; &nbsp;doesn&#39;t work because Drools sees it as different data<br>
 &nbsp; &nbsp;I am just guessing here ...<br>
<br>
<br>
 &nbsp; &nbsp;On Fri, Feb 13, 2009 at 9:12 AM, Przemysław Różycki<br></div><div class="Ih2E3d">
 &nbsp; &nbsp;&lt;<a href="mailto:P.Rozycki@amg.net.pl" target="_blank">P.Rozycki@amg.net.pl</a> &lt;mailto:<a href="mailto:P.Rozycki@amg.net.pl" target="_blank">P.Rozycki@amg.net.pl</a>&gt;&gt; wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Hello,<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Doesn&#39;t really anyone have any logical explanation of why such a<br>
 &nbsp; &nbsp; &nbsp; &nbsp;rule loops?<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;To remind the rule:<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;rule &quot;Hello World&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; no-loop<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $fact1 : MyFactBean1( &nbsp;)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $fact2 : MyFactBean2( &nbsp;) from $fact1<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; then<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;Fired!!!&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; update($fact1);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;end<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;If I don&#39;t use &#39;from&#39; everything is fine.<br>
 &nbsp; &nbsp; &nbsp; &nbsp;I really didn&#39;t find in a documentation, that &#39;from&#39; causes any<br>
 &nbsp; &nbsp; &nbsp; &nbsp;special behaviour of the rule looping.<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Best regards,<br>
 &nbsp; &nbsp; &nbsp; &nbsp;--  &nbsp; &nbsp; &nbsp; &nbsp;Przemysław Różycki<br>
 &nbsp; &nbsp; &nbsp; &nbsp;AMG.net, A Bull Group Company<br>
 &nbsp; &nbsp; &nbsp; &nbsp;ul. Ł±kowa 29<br>
 &nbsp; &nbsp; &nbsp; &nbsp;90-554 ŁódĽ<br></div>
 &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.amg.net.pl" target="_blank">www.amg.net.pl</a> &lt;<a href="http://www.amg.net.pl" target="_blank">http://www.amg.net.pl</a>&gt;<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Przemysław Różycki pisze:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Thanks for answer, Vikrant, but I don&#39;t think so. I have<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;always used no-loop without any additions and it worked<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(when I didn&#39;t use from). BTW, if you comment a condition<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;with from, then the rule does not loop. I also checked with<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;no-loop true&quot; and result is the same.<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Best regards,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Przemek<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Vikrant Yagnick pisze:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;I have to quickly recheck the documentation by I think<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;you have to write &quot;no-loop true&quot;. Just writing no-loop<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;defaults to false I guess.<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-----Original Message-----<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;From: <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>&gt;] On Behalf<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Of Przemyslaw Rózycki<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sent: Tuesday, February 10, 2009 3:24 PM<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To: Rules Users List<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Subject: [rules-users] Rules with from always loops<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(Drools 4.0.7)<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Hello,<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;why does such a rule always loop? Even if no-loop is used?<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rule &quot;Hello World&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; no-loop<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $fact1 : MyFactBean1( &nbsp;)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $fact2 : MyFactBean2( &nbsp;) from $fact1<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; then<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;Fired!!!&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; update($fact1);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The full code of my test application and drl is attached.<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Best regards,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Przemysław Różycki<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AMG.net, A Bull Group Company<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ul. Ł±kowa 29<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;90-554 ŁódĽ<br></div></div>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.amg.net.pl" target="_blank">www.amg.net.pl</a> &lt;<a href="http://www.amg.net.pl" target="_blank">http://www.amg.net.pl</a>&gt;<div class="Ih2E3d"><br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MASTEK LTD.<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Mastek is in NASSCOM&#39;s &#39;India Top 20&#39; Software Service<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Exporters List.<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;In the US, we&#39;re called MAJESCOMASTEK<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Opinions expressed in this e-mail are those of the<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;individual and not that of Mastek Limited, unless<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;specifically indicated to that effect. Mastek Limited<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;does not accept any responsibility or liability for it.<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;This e-mail and attachments (if any) transmitted with it<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;are confidential and/or privileged and solely for the<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;use of the intended person or entity to which it is<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;addressed. Any review, re-transmission, dissemination or<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;other use of or taking of any action in reliance upon<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this information by persons or entities other than the<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;intended recipient is prohibited. This e-mail and its<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;attachments have been scanned for the presence of<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;computer viruses. It is the responsibility of the<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;recipient to run the virus check on e-mails and<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;attachments before opening them. If you have received<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this e-mail in error, kindly delete this e-mail from<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;desktop and server.<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_______________________________________________<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rules-users mailing list<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br></div>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&gt;<div class="Ih2E3d"><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_______________________________________________<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rules-users mailing list<br></div>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a> &lt;mailto:<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&gt;<div class="Ih2E3d">
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;_______________________________________________<br>
 &nbsp; &nbsp; &nbsp; &nbsp;rules-users mailing list<br></div>
 &nbsp; &nbsp; &nbsp; &nbsp;<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a> &lt;mailto:<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&gt;<div class="Ih2E3d">
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
 &nbsp; &nbsp;_______________________________________________<br>
 &nbsp; &nbsp;rules-users mailing list<br></div>
 &nbsp; &nbsp;<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a> &lt;mailto:<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&gt;<div class="Ih2E3d">
<br>
 &nbsp; &nbsp;<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
<br>
-- <br>
&nbsp;Edson Tirelli<br>
&nbsp;JBoss Drools Core Development<br></div>
&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a> &lt;<a href="http://www.jboss.com" target="_blank">http://www.jboss.com</a>&gt;<br>
<br>
<br>
------------------------------------------------------------------------<div class="Ih2E3d"><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>
</div></blockquote><div><div></div><div class="Wj3C7c">
_______________________________________________<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> &nbsp;Edson Tirelli<br> &nbsp;JBoss Drools Core Development<br> &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>