<br>&nbsp;&nbsp; Eric,<br><br>&nbsp;&nbsp; For now, the way to do identity checks is to use an inline eval:<br><br>when<br>&nbsp;&nbsp;&nbsp; $a : Fact()<br>&nbsp;&nbsp;&nbsp; $b : Fact( eval( $a == $b ) )<br>then<br>&nbsp;&nbsp;&nbsp; // $a and $b are identical<br>end<br><br>&nbsp;&nbsp; []s<br>
&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2007/10/18, Eric Miles &lt;<a href="mailto:eric.miles@kronos.com">eric.miles@kronos.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
In java, I can check to see if a 2 variables references the same<br>instance as such:<br><br>Object a = new Object();<br>Object b = a;<br><br>a == b<br><br><br><br><br>Is there a way to do this in Drools?&nbsp;&nbsp;For instance, if there is an
<br>object in working memory and it is a specific instance, I do not want to<br>fire the rule again.&nbsp;&nbsp;ie:<br><br>rule &quot;User Lookup UserKey&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp; salience 10000<br>&nbsp;&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; com.kronos.taws.model.User
(empId == null, $key:empIdKey)<br>&nbsp;&nbsp;&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&quot;Firing 2!&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insert($key);<br><br>end<br><br>I want to ensure that $key is not already in working memory.&nbsp;&nbsp;But mind<br>you, there might be other $keys that are in working memory that do not
<br>belong to this particular com.kronos.taws.model.User instance.&nbsp;&nbsp;I do not<br>want this rule to fire because I have subsequent rules that will make<br>empId a value other than null.<br><br>I attempted to do this:<br><br>
rule &quot;User Lookup UserKey&quot;<br>&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;&nbsp;com.kronos.taws.model.User(empId == null, $key:empIdKey)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not UserKey(this == $key)<br>&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;&nbsp;System.out.println
(&quot;Firing 2!&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;insert($key);<br><br>end<br><br>However, I still think this is doing an equality check because once the<br>$key object is updated in another rule, this rule is fired again!<br><br>
Thanks in advance!<br>Eric<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">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646
<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>