Yes, I understand the problem of identity (EOF which is the persitence layer
we use in WebObjects has to deal with the same issues).
So, in fact, as long as you don't re-implement hashCode and equals (or that
their values don't change during the lifetime of the object), then there
will be no problem.
Alex
On 8.10.2002 14:06, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> Object identity is a slippery concept. Consider that two Strings
> containing the same text are "equal," but they are two different
> objects. Now, consider that two arrays containing the same values, and
> of the same length, are *not* equal according to the "equals()"
> method. Finally, consider that some classes have equals() methods that
> depend on mutable data, so that two objects may be equal now, but not
> equal a second from now (all the Collectioins classes are like this.)
>
> Anyway, here's an experiment to try. The following little program
> shows what happens if you use objects whose hashValue()s can change as
> the keys in a HashMap. The HashMap gets quite confused, as you'll
> see. The same kind of thing can happen to Jess if the the data in a
> slot changes in an uncontrolled way. As long as 1) all changes are
> announced by PropertyChangeEvents, and 2) the actual definstanced
> object's hashCode doesn't change, however, things work fine.
>
> ----------------------------------------------------------------------
> import java.util.HashMap;
>
> public class Test {
> private int m_i;
> public Test(int i) {
> m_i = i;
> }
>
> public void setHashCode(int i) {
> m_i = i;
> }
>
> public int hashCode() {
> return m_i;
> }
>
> public boolean equals(Object o) {
> if (o instanceof Test) {
> return m_i == ((Test) o).m_i;
> } else
> return false;
> }
>
> public static void main(String[] argv) {
>
> HashMap map = new HashMap();
> Test t1 = new Test(1);
> Test t2 = new Test(2);
>
> map.put(t1, "tee-one");
> map.put(t2, "tee-two");
>
> System.out.println(map.get(t1));
> System.out.println(map.get(t2));
>
> t1.setHashCode(9);
> t2.setHashCode(23);
>
> System.out.println(map.get(t1));
> System.out.println(map.get(t2));
> }
> }
> ----------------------------------------------------------------------
>
> I think Alexander Lamb wrote:
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
>> I am wondering if I might be affected by this problem as well since all my
>> facts will be definstances and some of them will be dynamic.
>> I thougt Jess was using hascode to handle a unique instance of the Java
>> object as a fact and by default hascode was returning a code different for
>> each object but immutable (for example the address of the object).
>> But somehow from this thread it looks like Jess is using properties to
>> identify unicity? Or is it my misunderstanding? Obviously, in a dynamic
>> object, properties will change! And I really don't want several copies of
>> facts of the same object in memory (representing in a way the history of the
>> object), because this would have side effects with:
>> - memory consumption
>> - how to make sure an undefinstance will remove them all
>>
>> Alexander
>>
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Distributed Systems Research Phone: (925) 294-2154
> Sandia National Labs FAX: (925) 294-2234
> Org. 8920, MS 9012 [EMAIL PROTECTED]
> PO Box 969 http://herzberg.ca.sandia.gov
> Livermore, CA 94550
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify [EMAIL PROTECTED]
> --------------------------------------------------------------------
>
--
Alexander Lamb
Groupe Serveurs Applicatifs
Division d'Informatique Midicale
Htpitaux Universitaires de Genhve
21 rue Micheli-du-Crest
CH-1211 Genhve 4 / Switzerland
Tel: +41-22 372.48.46 Fax: +41-22 382.86.80
[EMAIL PROTECTED] / http://www.hcuge.ch
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------