1 Reply Latest reply on Jan 29, 2002 5:01 PM by Dain Sundstrom

    PrimaryKey Classes and Marshalling Problem

    William Kaufman Newbie

      The hashCode and equals methods implemented by PrimaryKey classes are not used by JBoss (at least by default - see the CacheKey class). Instead, the hashCode and equals of the MarshalledObject constructed from the PK is used.

      This is fine if the serialization is done correctly (ie readObject() has been implemented right). Unfortunately, the BigInteger implementation in jdk1.3.1 has a number of fields that either should have been declared transient, or ... (your solution here). The upshot is if you use BigInteger (or BigDecimal - it has a BigInteger inside it) as your PK class or as part of your PK class, you are not guaranteed that the Marshalled object hashcode will be unique. This is bad news for the entity caching in JBoss 2.4.4 (haven't looked at 3.0, but I assume it's the same).

      Attached is a simple test to illustrate the problem.

      This problem bit us pretty hard. A bug report's been filed with Sun.

      BTW- if I'm off in left field here please let me know.