removed hash code calculation from constructor
This commit is contained in:
parent
a90c945bae
commit
4010beb3de
2 changed files with 10 additions and 8 deletions
|
@ -5,6 +5,7 @@ package helma.objectmodel;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the internal representation of a database key. It is constructed
|
* This is the internal representation of a database key. It is constructed
|
||||||
* out of the database URL, the table name, the user name and the database
|
* out of the database URL, the table name, the user name and the database
|
||||||
|
@ -15,7 +16,7 @@ public final class DbKey implements Key, Serializable {
|
||||||
|
|
||||||
private final String storageName;
|
private final String storageName;
|
||||||
private final String id;
|
private final String id;
|
||||||
private final int hash;
|
// private transient int hash;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,13 +25,10 @@ public final class DbKey implements Key, Serializable {
|
||||||
public DbKey (DbMapping dbmap, String id) {
|
public DbKey (DbMapping dbmap, String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.storageName = dbmap == null ? null : dbmap.getStorageTypeName ();
|
this.storageName = dbmap == null ? null : dbmap.getStorageTypeName ();
|
||||||
hash = id.hashCode ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean equals (Object what) {
|
public boolean equals (Object what) {
|
||||||
if (what == this)
|
|
||||||
return true;
|
|
||||||
try {
|
try {
|
||||||
DbKey k = (DbKey) what;
|
DbKey k = (DbKey) what;
|
||||||
return (storageName == k.storageName || storageName.equals (k.storageName)) &&
|
return (storageName == k.storageName || storageName.equals (k.storageName)) &&
|
||||||
|
@ -41,7 +39,8 @@ public final class DbKey implements Key, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode () {
|
public int hashCode () {
|
||||||
return hash;
|
return storageName == null ? id.hashCode () : storageName.hashCode() + id.hashCode ();
|
||||||
|
// return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Key getParentKey () {
|
public Key getParentKey () {
|
||||||
|
@ -115,5 +114,6 @@ public final class DbKey implements Key, Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ public final class SyntheticKey implements Key, Serializable {
|
||||||
|
|
||||||
private final Key parentKey;
|
private final Key parentKey;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int hash;
|
// private final int hash;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ public final class SyntheticKey implements Key, Serializable {
|
||||||
public SyntheticKey (Key key, String name) {
|
public SyntheticKey (Key key, String name) {
|
||||||
this.parentKey = key;
|
this.parentKey = key;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
hash = name.hashCode () + key.hashCode ();
|
// hash = name.hashCode () + key.hashCode ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,8 @@ public final class SyntheticKey implements Key, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode () {
|
public int hashCode () {
|
||||||
return hash;
|
// return hash;
|
||||||
|
return name.hashCode () + parentKey.hashCode ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,5 +115,6 @@ public final class SyntheticKey implements Key, Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue