OPENJPA-2348: Revert prior commit.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1453928 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Richard G. Curtis 2013-03-07 15:50:36 +00:00
parent 1e2b753afa
commit e0bb4cd7c7
1 changed files with 15 additions and 21 deletions

View File

@ -29,17 +29,16 @@ import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashMap;
* @author Steve Kim
*/
@SuppressWarnings("serial")
public abstract class OpenJPAId implements Comparable, Serializable {
public abstract class OpenJPAId
implements Comparable, Serializable {
public static final char TYPE_VALUE_SEP = '-';
// cache the types' generated hash codes
private static ConcurrentReferenceHashMap _typeCache =
new ConcurrentReferenceHashMap(ReferenceMap.WEAK, ReferenceMap.HARD);
protected Class<?> type;
protected Class type;
protected boolean subs = true;
private int _hc = -1;
// type hash is based on the least-derived non-object class so that
// user-given ids with non-exact types match ids with exact types
@ -107,27 +106,22 @@ public abstract class OpenJPAId implements Comparable, Serializable {
* so that it doesn't have to be generated each time.
*/
public int hashCode() {
if (_hc == -1) {
if (_typeHash == 0 && type != null) {
Integer typeHashInt = (Integer) _typeCache.get(type);
if (typeHashInt == null) {
Class base = type;
Class superclass = base.getSuperclass();
while (superclass != null && superclass != Object.class) {
base = base.getSuperclass();
superclass = base.getSuperclass();
}
_typeHash = base.getName().hashCode();
_typeCache.put(type, Integer.valueOf(_typeHash));
} else {
_typeHash = typeHashInt.intValue();
if (_typeHash == 0) {
Integer typeHashInt = (Integer) _typeCache.get(type);
if (typeHashInt == null) {
Class base = type;
Class superclass = base.getSuperclass();
while (superclass != null && superclass != Object.class) {
base = base.getSuperclass();
superclass = base.getSuperclass();
}
_hc = _typeHash ^ idHash();
_typeHash = base.getName().hashCode();
_typeCache.put(type, Integer.valueOf(_typeHash));
} else {
_hc = idHash();
_typeHash = typeHashInt.intValue();
}
}
return _hc;
return _typeHash ^ idHash();
}
public boolean equals(Object o) {