<br> Yes, that is the correct behavior and checking of equality will not help on that. If you want facts to match only in one way but not the reverse, you need to have some kind of "ordering" between them and must add a constraint to your rules to avoid that. Note that this is not a rules engine issue, but a model design issue.
<br> Example of how to solve that is:<br><br>* if your facts have an attribute with an ID/code/whatever that may be ordered, you can do:<br><br>when<br> MyFact( $id : id )<br> MyFact( id > $id )<br>then <br> ...
<br>end<br><br> So the ">" constraint will prevent facts matching both ways. <br> If you don't have such attribute, you can use system id, but that is ugly, and you probably could find a better modeling for your facts. Anyway, it would be like:
<br><br>when<br> $f1 : MyFact()<br> $f2 : MyFact()<br> eval( System.identityHashCode( $f1 ) > System.identityHashCode( $f2 ) )<br>then<br> ...<br>end<br> <br> Again, the above works, but is damn ugly... :)<br>
<br> []s<br> Edson<br><br><br><br><div><span class="gmail_quote">2007/5/20, Sikkandar Nawabjan <<a href="mailto:Sikkandar.Nawabjan@ustri.com">Sikkandar.Nawabjan@ustri.com</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>
<div><font face="Arial" size="2">Edson,</font></div>
<div><font face="Arial" size="2">am getting the following output</font></div>
<div><font face="Arial" size="2">[ b, a ]</font></div>
<div><font face="Arial" size="2">[ a, b ]</font><br>only the order of the output is
different. so if i check a equal to b according to the cross product law the
then part execute 2 times?</div>
<div>thats y i check the reference in the then part.</div>
<div> </div>
<div>how to use eval to variable comparison of objects in a single
line</div>
<div><br>Thanks and regs,</div>
<div>Basha</div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div><br> </div>
<div><font face="Arial" size="2"></font> </div>
<div><font color="#000000" face="Arial" size="2"></font> </div>
<div><font color="#000000" face="Arial" size="2">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////</font>
</div>
<div><font color="#000000" face="Arial" size="2">Message: 3<br>Date: Sat, 19 May 2007
09:53:29 -0300<br>From: "Edson Tirelli" <<a href="mailto:tirelli@post.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">tirelli@post.com</a>><br>Subject: Re:
[rules-users] [rule-users]how to create object
properties<br>
in single stmnt<br>To: "Rules Users List"
<<a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org</a>><br>Message-ID:<br>
<<a href="mailto:e6dd5ba30705190553p1f5f794ct91ad250fb1ad3753@mail.gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">e6dd5ba30705190553p1f5f794ct91ad250fb1ad3753@mail.gmail.com</a>><br>
Content-Type:
text/plain; charset="iso-8859-1"<br><br>
Sikkandar,<br><br> In 3.0.6, if you have 2 strings in the
working memory ("a" and "b" ) and<br>you write:<br><br>rule "cross
product"<br>when<br> $s1: String()<br> $s2:
String()<br>then<br> System.out.println("[ "+$s1+", "+$s2+"
]");<br>end<br><br> The result MUST be:<br><br>[ a, b ]<br>[ b, a
]<br><br> If it is not that, then we have a bug, but our integration
tests that<br>test this specific situation are working fine. Plz let us know if
it is<br>different for you.<br> In 4.0, the result must be:<br><br>[
a, b ]<br>[ b, a ]<br>[ a, a ]<br>[ b, b ]<br><br> So a fact (by
default) may match multiple simultaneous patterns.<br><br> Regarding
your second question, comparing properties of the same object<br>is also
something we added for 4.0. In 3.0.x you need eval() too.<br><br>
[]s<br> Edson<br><br>2007/5/19, Sikkandar Nawabjan
<<a href="mailto:Sikkandar.Nawabjan@ustri.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Sikkandar.Nawabjan@ustri.com</a>>:<br>><br>> Hi ,<br>> The very
reason i used to compare two object reference is that i got then<br>>
executed multiple time when i do duplicate check between object
properties.<br>> so i beleive the pattern match happen more than a
time<br>> for example<br>>
when<br>>
$obj1:object($code:code,$stdate:startdate);<br>>
$obj2:object(code==$code,startdate=$stdate);<br>> then<br>>
if(obj1!=obj2)<br>>
System.out.println("Fired");<br>><br>> My questions are<br>><br>> 1)
In 3.0.6 is there any other way to avoid this multiple check other than<br>>
using eval(which affects performance i beleive). i can't use this
operator<br>> in 3.0.6<br>><br>> 2) related to this i have one more
query. how to check properties within<br>> the object itself<br>><br>>
for example i want to do<br>>
when<br>>
$obj1:object($code:code,$stdate:startdate,$enddate:enddate > $stdate,<br>>
reasoncode == $code);<br>> then<br>>
System.out.println("Fired");<br>> i beleive the above throws error in 3.0.6
(nullpointer related to alpha<br>> node)<br>><br>> Earlier reply is
highly appreciated<br>><br>> Thanks and Regs,<br>>
Bassha<br>><br>><br></font></div></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><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @
<a href="http://www.jboss.com">www.jboss.com</a>