You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2004/04/08 01:58:00 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker Identity.java
arminw 2004/04/07 16:58:00
Modified: src/java/org/apache/ojb/broker Identity.java
Log:
Fix by Guillaume Nodet - declare hashCode and toString fields transient.
> The Identity class caches internally the hash code
> and the string representation in private attributes.
> These attributes are not declared transient, thus
> the computed hash code is serialized. The problem is
> that the Class.hashCode() method not overriden
> and so relies on the Object.hashCode() method which
> is not guaranteed to give the same values when
> serialized/deserialized.
Revision Changes Path
1.35 +12 -4 db-ojb/src/java/org/apache/ojb/broker/Identity.java
Index: Identity.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/Identity.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- Identity.java 4 Apr 2004 23:53:30 -0000 1.34
+++ Identity.java 7 Apr 2004 23:58:00 -0000 1.35
@@ -41,7 +41,9 @@
*/
public class Identity implements Serializable
{
- static final long serialVersionUID = 3182285550574178710L; /**
+ static final long serialVersionUID = 3182285550574178710L;
+
+ /**
* the top-level Class of the identified object<br>
* ie: an Interface
*/
@@ -57,8 +59,14 @@
* The ordered list of primary key values maintaining the objects identity in the underlying RDBMS
*/
private Object[] m_pkValues;
- private String m_stringRepresentation = null;
- private Integer m_hashCode;
+
+ /*
+ In distributed enviroments the Identity object have to recalculate the
+ hashCode and toString values, because the hash code of the Class object
+ differs in different JVM
+ */
+ private transient String m_stringRepresentation = null;
+ private transient Integer m_hashCode;
/**
* creates an Identity from a class and the objects primary key values.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org