Perhaps I should elaborate what I was hinting at with my joke (&quot;Joneses&quot;).<br><br>A Java object (pojo) can be duplicated so that the new object will not<br>have the same identity (as tested by &quot;==&quot;). Its equals() method will return<div>
true if applied to this pair of pojos. This method may still return true after changing</div><div>certain properties, as it is generally customary to make the assumption that</div><div>some properties (primary key) uniquely identify the real world entity a pojo </div>
<div>represents. Also note that applications are usually based on a 1:1 relationship</div><div>between entities and pojos.</div><div><br>When we insert pojos as facts we have to contend with the notion that<br>facts represent truths. It does not make sense to insert a clone (i.e, another<br>
pojo instance with all properties being the same) of a fact - it can&#39;t be truer<br>than true. But it <i>might</i> make sense to insert another object relating to the<br>same real world entity, i.e., Entity.equals() returning true, but not <i>all</i> properties<br>
being equal, for instance two observations of the same thing, at different<div>times or by different observers.<br><br></div><div>In other words, an equals() that works well for testing the identity of entities</div><div>
represented by pojos is usually not the same as an equals() testing the</div><div>sameness of a fact. </div><div><br>-W<br><br>On 26/02/2012, Mark Proctor &lt;<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt; wrote:<br>
&gt; There are two types of facts - stated and justified. As explained in the<br>&gt; TMS section.<br>&gt;<br>&gt; Justified facts are ALWAYS equality based, as it&#39;s the nature of TMS.<br>&gt; The other part of engine for stated facts is customizable and may work<br>
&gt; in either equality mode or identity mode. Identity mode is default, as<br>&gt; it&#39;s the most common way  java developers expect to work, knowledge<br>&gt; based engineers may prefer eqality mode.<br>&gt;<br>&gt; We do discuss this in the maual. If it&#39;s clear, then please do help beef<br>
&gt; up the docs on this. Fork the docs and submit a pull request, see:<br>&gt; <a href="http://www.athico.com/Getting_Involved/gettinginvolved.html">http://www.athico.com/Getting_Involved/gettinginvolved.html</a><br>&gt;<br>
&gt; Mark<br>&gt; On 25/02/2012 19:41, SirMungus wrote:<br>&gt;&gt; By the way, while checking into various scenarios prompted by Wolfgang&#39;s<br>&gt;&gt; response, I came up with a very interesting test program:<br>&gt;&gt;<br>
&gt;&gt; rule &quot;Initialize&quot;<br>&gt;&gt;      salience 100<br>&gt;&gt;      when<br>&gt;&gt;          eval(true)<br>&gt;&gt;      then<br>&gt;&gt;          insert(&quot;one&quot;);<br>&gt;&gt;          insert(new String(&quot;one&quot;));<br>
&gt;&gt;          insertLogical(&quot;two&quot;);<br>&gt;&gt;          insertLogical(new String(&quot;two&quot;));<br>&gt;&gt; end<br>&gt;&gt;<br>&gt;&gt; rule &quot;Find strings&quot;<br>&gt;&gt;      salience 50<br>&gt;&gt;      when<br>
&gt;&gt;          $s : String()<br>&gt;&gt;      then<br>&gt;&gt;          System.out.println(&quot;I found string: &quot; + $s);<br>&gt;&gt; end<br>&gt;&gt;<br>&gt;&gt; rule &quot;Gather strings&quot;<br>&gt;&gt;      salience 50<br>
&gt;&gt;      when<br>&gt;&gt;          accumulate(<br>&gt;&gt;              $s : String(),<br>&gt;&gt;              $sSet : collectSet( $s ),<br>&gt;&gt;              $sList : collectList( $s ) )<br>&gt;&gt;      then<br>
&gt;&gt;          System.out.println(&quot;Here is the set of all strings: &quot; + $sSet);<br>&gt;&gt;          System.out.println(&quot;Here is the list of all strings: &quot; + $sList);<br>&gt;&gt; end<br>&gt;&gt;<br>&gt;&gt; What would you expect that to output? How many &quot;I found string: xxx&quot; lines<br>
&gt;&gt; would there be? How many entries in the &quot;set of all strings&quot;? How many<br>&gt;&gt; entries in the &quot;list of all strings&quot;?<br>&gt;&gt;<br>&gt;&gt; For my part, I figured there would be four &quot;I found string: xxx&quot; lines,<br>
&gt;&gt; two<br>&gt;&gt; entries in the set, and four entries in the list.<br>&gt;&gt;<br>&gt;&gt; I was very surprised to find the following output:<br>&gt;&gt;<br>&gt;&gt; I found string: two<br>&gt;&gt; I found string: one<br>
&gt;&gt; I found string: one<br>&gt;&gt; Here is the set of all strings: [two, one]<br>&gt;&gt; Here is the list of all strings: [one, one, two]<br>&gt;&gt;<br>&gt;&gt; This strongly suggests that &quot;insert&quot; objects are held in an<br>
&gt;&gt; identity-preserving structure, but that &quot;insertLogical&quot; objects are held<br>&gt;&gt; in<br>&gt;&gt; an equals()-based structure.<br>&gt;&gt;<br>&gt;&gt; I am glad for the identity-based handling of &quot;insert&quot; objects, especially<br>
&gt;&gt; considering that all of my inserted objects come from &quot;outside&quot; the<br>&gt;&gt; engine.<br>&gt;&gt; I would hate to see one of them fail to be considered by the rule engine.<br>&gt;&gt;<br>&gt;&gt; I can almost see some usefulness for the equals() behavior of<br>
&gt;&gt; insertLogical<br>&gt;&gt; objects, but far more potential problems.<br>&gt;&gt;<br>&gt;&gt; I think it&#39;s slightly dangerous that these behaviors differ and that it is<br>&gt;&gt; not, AFAIK, documented in a way that is clear to users of Drools.<br>
&gt;&gt;<br>&gt;&gt; --<br>&gt;&gt; View this message in context:<br>&gt;&gt; <a href="http://drools.46999.n3.nabble.com/BUG-5-3-0-Final-CollectSetAccumulateFunction-should-probably-use-IdentityHashMap-internally-tp3774079p3775619.html">http://drools.46999.n3.nabble.com/BUG-5-3-0-Final-CollectSetAccumulateFunction-should-probably-use-IdentityHashMap-internally-tp3774079p3775619.html</a><br>
&gt;&gt; Sent from the Drools: Developer (committer) mailing list mailing list<br>&gt;&gt; archive at Nabble.com.<br>&gt;&gt; _______________________________________________<br>&gt;&gt; rules-dev mailing list<br>&gt;&gt; <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>&gt;<br>&gt; _______________________________________________<br>&gt; rules-dev mailing list<br>
&gt; <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>&gt;<br></div></div>