<br>&nbsp;&nbsp; Chris<br><br>&nbsp;&nbsp; Version 3.0.x prevents by default a single fact from matching multiple patterns. For a couple of reasons we had to change the default in 4.0 to allow a single fact to match multiple patterns. If you don&#39;t want this to happen, you can use one of the following approaches:
<br><br>* Change the behavior for the whole rulebase. You can do that by either setting a system property (&quot;drools.removeIdentities=true&quot;) or creating a RuleBaseConfiguration instance:<br><br>RuleBaseConfiguration conf = new RuleBaseConfiguration();
<br>conf.setRemoveIdentities( true );<br>RuleBase rulebase = new ReteooRuleBase( conf );<br><br>* Alternativelly, you can manually add a constraint to avoid the behavior for specific rules, using the &quot;this&quot; keyword.
<br><br>rule &quot;TwoCheeses&quot;
<br>&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $cheese1 : Cheese();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $cheese2 : Cheese( this != $cheese1 );&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; then <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println($cheese1);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println($cheese2);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println
(&quot;TwoCheeses&quot;);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
<br>end<br><br><br>&nbsp;&nbsp;&nbsp; We will add such information to the documentation, but the above shall give you the idea.<br><br>&nbsp;&nbsp;&nbsp; Hope it helps,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2007/5/15, Chris Woodrow &lt;
<a href="mailto:woodrow.chris@gmail.com">woodrow.chris@gmail.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;">Hi everyone,
<br>I am new to this mailing list, I&#39;ve had a quick look at archives and didn&#39;t find anything ont this subject but sorry if this has allready been underlined.<br><br>Here is my problem, while I was doing some test on 
v3.0.6, 4.0.0 came out, so I started to migrate on the new version. Then I found out an unexpecteed behavior on the 4.0.0.<br><br>I have been compiling both with Java 5 and running whith Java 1.5.0_11. And I used versions with dependencies on both tests.
<br><br>I have made an exemple for you to make it as clear as possible, here is the rule :<br><br>---------------------------------------------------------------------------------------<br>package rules<br><br>rule &quot;TwoCheeses&quot;
<br>&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $cheese1 : Cheese();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $cheese2 : Cheese();&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; then <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println($cheese1);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println($cheese2);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println(&quot;TwoCheeses&quot;);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
<br>end<br>---------------------------------------------------------------------------------------<br><br>When I run it on V3.0.6, with this code :<br><br>---------------------------------------------------------------------------------------
<br>package rules;<br><br>import java.io.InputStreamReader;<br><br>import org.drools.RuleBase;<br>import org.drools.RuleBaseFactory;<br>import org.drools.WorkingMemory;<br>import org.drools.compiler.PackageBuilder;<br><br>

public class Cheese {<br>&nbsp;&nbsp;&nbsp; public static void main(String[] args) throws Exception{<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; PackageBuilder builder = new PackageBuilder();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; builder.addPackageFromDrl(new InputStreamReader(Cheese.class.getResourceAsStream

(&quot;rule.drl&quot;)));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ruleBase.addPackage(builder.getPackage());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WorkingMemory workingMemory = ruleBase.newWorkingMemory

();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Cheese cheese = new Cheese();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; workingMemory.assertObject(cheese);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; workingMemory.fireAllRules();<br>&nbsp;&nbsp;&nbsp; }<br>}<br>---------------------------------------------------------------------------------------
<br><br>The rule doesn&#39;t fire, which is normal AMHA since only one Cheese object is asserted to the WM<br><br>When I run it on V4.0.0, whith this code :<br>---------------------------------------------------------------------------------------
<br>package rules;<br><br>import java.io.InputStreamReader;<br><br>import org.drools.RuleBase;<br>import org.drools.RuleBaseFactory;<br>import org.drools.StatefulSession;<br>import org.drools.compiler.PackageBuilder;<br>
<br>
public class Cheese {<br>&nbsp;&nbsp;&nbsp; public static void main(String[] args) throws Exception{<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; PackageBuilder builder = new PackageBuilder();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; builder.addPackageFromDrl(new InputStreamReader(Cheese.class.getResourceAsStream

(&quot;rule.drl&quot;)));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ruleBase.addPackage(builder.getPackage());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; StatefulSession statefulSession = 
ruleBase.newStatefulSession(); <br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Cheese cheese = new Cheese();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; statefulSession.assertObject(cheese);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; statefulSession.fireAllRules();<br>&nbsp;&nbsp;&nbsp; }<br>}<br>---------------------------------------------------------------------------------------
<br>Now the rule fires and $cheese1 $cheese2 have the same reference.<br><br>I have been searching in all docs, this modification of behavior doesn&#39;t seem to be expected, has anyone noticed this?<br><br>Thanks for your help.
<br><span class="sg"><br>Chris<br><br><br>
</span><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>&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>