<div dir="ltr"><br>&nbsp;&nbsp; Oh, I see. <br><br>&nbsp;&nbsp; Unfortunately in this case, there is nothing we can do about it, because the rules are behaving exactly as they were supposed to behave:<br><br>NegativeResult(applicant == $applicant)<br>
<br>&nbsp;&nbsp; As you can see, they are telling the application to use the equals comparison in the constraint:<br><br>applicant == $applicant<br><br>&nbsp;&nbsp; A fact should not change it&#39;s identity once it is asserted, so, either you use a constant &quot;equals()/hashcode()&quot; implementation, or you use constraints on an immutable ID:<br>
<br>NegativeResult(applicantId == $<a href="http://applicant.id">applicant.id</a>)<br><br>&nbsp;&nbsp; You can also fallback to java &quot;identity&quot; check by using eval, but it is ugly... :)<br><br>NegativeResult( eval( applicant == $applicant) )<br>
<br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><br><div class="gmail_quote">2008/8/4  <span dir="ltr">&lt;<a href="mailto:ringsah@comcast.net">ringsah@comcast.net</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>Edson,</div>
<div>&nbsp;</div>
<div>I finally succeeded in coming up with a simple test case that shows the problem. I have attached the necessary files, which include a test case, three fact objects, and the drl.</div>
<div>&nbsp;</div>
<div>One&nbsp;key to this test are the fact that the Applicant fact object has an &quot;equals&quot; method that tests for equality of its attributes, rather than identity.&nbsp;A second&nbsp;key is that the applicant object is updated after it is inserted.</div>

<div>&nbsp;</div>
<div>It appears that what is happening is that an activation is created for the rule that uses &quot;not&quot; when the applicant is inserted. Then, when the applicant is updated, a second activation is created for that rule. It should be cancelling the previous activation, but doesn&#39;t find it because the Applicant instance no longer &quot;equals&quot; the fact object that caused the activation.</div>

<div>&nbsp;</div>
<div>Thanks!</div>
<div>-Hans</div>
<blockquote style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;"><div class="Ih2E3d">-------------- Original message -------------- <br>From: &quot;Edson Tirelli&quot; &lt;<a href="mailto:tirelli@post.com" target="_blank">tirelli@post.com</a>&gt; <br>

</div><div dir="ltr"><div class="Ih2E3d"><br>&nbsp;&nbsp; Hans, <br><br>&nbsp;&nbsp; Your reasoning is correct. There should not be 2 instances of ApplicantStatus in the working memory. <br><br>&nbsp;&nbsp; Can you provide a test case showing the problem? we have test cases here using &quot;not&quot; and logical assertions, and it works properly.<br>
<br>&nbsp;&nbsp; Thanks,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edson<br><br>
</div><div class="gmail_quote">2008/7/31 <span dir="ltr">&lt;<a href="mailto:ringsah@comcast.net" target="_blank">ringsah@comcast.net</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 class="Ih2E3d"><font size="2">
<p>How is &quot;</p></font><font size="2" face="Courier New">not</font><font size="2">&quot; supposed to work with </font><font size="2" face="Courier New">insertLogical</font><font size="2">? Assume I have two different rules whose conditions are mutually exclusive, like the following:</font><b><font color="#960000" size="2" face="Courier New"> 
<p>rule</p></font></b><font size="2" face="Courier New"></font><font color="#008000" size="2" face="Courier New">&quot;</font><font color="#008000" size="2" face="Courier New">Rule One</font><font color="#008000" size="2" face="Courier New">&quot;</font><font size="2" face="Courier New"> 
<p></p></font><b><font color="#960000" size="2" face="Courier New">when</font></b><font size="2" face="Courier New"> 
<p></p></font><font size="2" face="Courier New">not NegativeResult()</font><font size="2" face="Courier New"> 
<p></p></font><b><font color="#960000" size="2" face="Courier New">then</font></b><font size="2" face="Courier New"> 
<p></p></font><b><font color="#960000" size="2" face="Courier New">insertLogical</font></b><font size="2" face="Courier New">(</font><font size="2" face="Courier New">new ApplicantStatus(&quot;Approved&quot;)</font><font size="2" face="Courier New">);</font><b><font color="#960000" size="2" face="Courier New"> 
<p>end</p></font></b><font size="2" face="Courier New"></font><b><font color="#960000" size="2" face="Courier New">
<p>rule</p></font></b><font size="2" face="Courier New"></font><font color="#008000" size="2" face="Courier New">&quot;</font><font color="#008000" size="2" face="Courier New">Rule Two</font><font color="#008000" size="2" face="Courier New">&quot;</font><font size="2" face="Courier New"> 
<p></p></font><b><font color="#960000" size="2" face="Courier New">when</font></b><font size="2" face="Courier New"> 
<p></p></font><font size="2" face="Courier New">NegativeResult()</font><font size="2" face="Courier New"> 
<p></p></font><b><font color="#960000" size="2" face="Courier New">then</font></b><font size="2" face="Courier New"> 
<p></p></font><b><font color="#960000" size="2" face="Courier New">insertLogical</font></b><font size="2" face="Courier New">(</font><font size="2" face="Courier New">new ApplicantStatus(&quot;Denied&quot;)</font><font size="2" face="Courier New">);</font><b><font color="#960000" size="2" face="Courier New"> 
<p>end</p></font></b><font size="2" face="Courier New"></font><font size="2">
<p>Assume that the above two rules are the only way an </p></font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> fact can be inserted into working memory. I would expect, after all rules are run, that it would be impossible for there to be one </font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> with </font><font size="2" face="Courier New">&quot;Approved&quot;</font><font size="2"> as its reason, and another with </font><font size="2" face="Courier New">&quot;Denied&quot;</font><font size="2"> as its reason, in the working memory. 
<p>I would expect that, before any </p></font></div><font size="2" face="Courier New">NegativeResult</font><font size="2"> is inserted, that rule one could run, and insert an </font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> fact with an </font><font size="2" face="Courier New">&quot;Approved&quot;</font><font size="2"> reason. Then, after a </font><font size="2" face="Courier New">NegativeResult</font><font size="2"> is inserted, that rule two could run, and insert an </font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> fact with a </font><font size="2" face="Courier New">&quot;Denied&quot;</font><font size="2"> reason. At this point I would expect that the original </font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> fact, with an </font><font size="2" face="Courier New">&quot;Approved&quot;</font><font size="2"> reason, would be retracted, since the conditions under which it was inserted are no lon! ger true. 
<div class="Ih2E3d"><p>This is not what I am observing, however. I am finding </p></div></font><div class="Ih2E3d"><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> facts with both reasons in working memory at the end of the rules run. Should &quot;not&quot; work as I expect with regard to inserting a fact via </font><font size="2" face="Courier New">insertLogical()</font><font size="2">? Or is this a known limitation, or simply the way it is designed to work? 
<p>Thanks,</p>
<p>-Hans</p></font></div></div></div><div class="Ih2E3d"><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></div></blockquote></div><br><br clear="all"><br><div class="Ih2E3d">-- <br>Edson Tirelli<br>
JBoss Drools Core Development<br>JBoss, a division of Red Hat @ <a href="http://www.jboss.com/" target="_blank">www.jboss.com</a><br></div></div></blockquote></div></div>
<br><br>---------- Mensagem encaminhada ----------<br>From:&nbsp;<a href="mailto:ringsah@comcast.net">ringsah@comcast.net</a><br>To:&nbsp;Rules Users List &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>
Date:&nbsp;Mon, 04 Aug 2008 13:49:37 +0000<br>Subject:&nbsp;Re: [rules-users] &quot;Not&quot; Non-Existential Quantifier<br><br><br>---------- Mensagem encaminhada ----------<br>From:&nbsp;&quot;Edson Tirelli&quot; &lt;<a href="mailto:tirelli@post.com">tirelli@post.com</a>&gt;<br>
To:&nbsp;&quot;Rules Users List&quot; &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>Date:&nbsp;Thu, 31 Jul 2008 17:41:39 +0000<br>Subject:&nbsp;Re: [rules-users] &quot;Not&quot; Non-Existential Quantifier<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>_______________________________________________<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>
</div>