What happens if you insert two Product/Option pairs, one with the price already set and the other still with price == null?<br><br>One thing that could explain the effect you describe it is calling<br>   ksession.fireAllRules( 1 )<br>
to run the engine. If this isn&#39;t the cause, we&#39;d need to see all the code, in a minimum examle to reproduce this.<br><br>-W<br><br><div class="gmail_quote">On 5 April 2011 05:38, groovenarula <span dir="ltr">&lt;<a href="mailto:gnarula1@la-z-boy.com">gnarula1@la-z-boy.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello all,<br>
<br>
For some reason I have a rule that does not fire after a Modify/Update.<br>
<br>
I have 2 facts - Product and Option. The relationship between them is that a<br>
&#39;Product&#39; can have 0 - N &#39;Option&#39;(s).<br>
<br>
Based on that, I added a &#39;product&#39; field to the &#39;Option&#39; object. I&#39;m<br>
creating and inserting my facts<br>
using the following code :<br>
<br>
                        Product prod = new Product (&quot;001&quot;,&quot;002&quot;, &quot;A&quot;);<br>
                        prod.setPrice(new BigDecimal(&quot;300.00&quot;));<br>
                        Option opt = new Option (&quot;H1&quot;,&quot;&quot;,prod);<br>
<br>
                        ksession.insert(prod);<br>
                        ksession.insert(opt);<br>
<br>
<br>
Now in my .DLR, I have the following rule :<br>
<br>
rule &quot;Set Options price&quot;<br>
        salience 50<br>
<br>
        when<br>
<br>
                $prod : Product ( price != null )<br>
                $option : Option ( product == $prod )<br>
<br>
        then<br>
<br>
                System.out.println( &quot;Getting Options &quot; + $prod );<br>
<br>
end<br>
<br>
This gives me the correct output in the console :<br>
<br>
  Getting Options Product [category=001, grade=A, price=300.00, style=002]<br>
<br>
The rule fired successfully.<br>
<br>
I start running into problems when I try to update the &#39;price&#39; field using a<br>
rule, instead of through code.<br>
<br>
So for example, if I have the following rule also defined in the same drl<br>
file :<br>
<br>
rule &quot;Set price&quot;<br>
        salience 500<br>
<br>
        when<br>
<br>
                $prod : Product ( category == &quot;001&quot;, price == null )<br>
<br>
        then<br>
<br>
                $prod.setPrice ( new BigDecimal ( &quot;300.00&quot; ) );<br>
                update( $prod );<br>
                System.out.println( $prod );<br>
<br>
end<br>
<br>
And then change my code as follows (remove the setPrice call) :<br>
<br>
                Product prod = new Product (&quot;001&quot;,&quot;002&quot;, &quot;A&quot;);<br>
                Option opt = new Option (&quot;H1&quot;,&quot;&quot;,prod);<br>
<br>
                ksession.insert(prod);<br>
                ksession.insert(opt);<br>
<br>
I only get the following output :<br>
<br>
Product [category=001, grade=A, price=300.00, style=002]<br>
<br>
What am I missing here ? I thought the rule &#39;Set Price&#39; should update the<br>
product fact with<br>
the new price and the rules would get re-evaluated. After the re-evaluation,<br>
the LHS of &#39;Set Options Price&#39; should now be true and it should have fired.<br>
But it does not.<br>
<br>
Am I mis-understanding something about activation here ? If I am, can<br>
someone please help explain what the gap is and how to re-write the rules so<br>
that I can achieve the above objective ?<br>
<br>
Any help will be appreciated. I&#39;ve spend several hours trying different<br>
permutations and combinations and got no where.<br>
<br>
Thanks<br>
Gurvinder<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Rule-does-not-fire-after-Modify-Update-of-a-fact-Drools-5-1-1-tp2778508p2778508.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Rule-does-not-fire-after-Modify-Update-of-a-fact-Drools-5-1-1-tp2778508p2778508.html</a><br>

Sent from the Drools - User mailing list archive at Nabble.com.<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>
</font></blockquote></div><br>