I cam to think, can it be my hashcode function?
Code:
/*
* Created on Feb 2, 2005
*
*/
package data;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import frontend.util.IDUtil;
import frontend.util.PathHolder;
/**
* Represents a person in the system. Do not init this class,
* factory.PersonFactory instead
* @author Oliver Billing
*
*/
public class Person implements ContainsFiles {
private int uniqueID = IDUtil.getInstance().getUniqueID();
/** The composite primary key value. */
protected java.lang.Integer personId;
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
protected int hashValue = 0;
/**Full name of person*/
protected java.lang.String name;
/** The value of the simple handle property. */
protected java.lang.String handle;
/** The value of the simple password property. */
protected java.lang.String password;
/** The value of the simple createddate property. */
protected java.lang.Long createddate;
/** Projects that the person has access too*/
protected Set projects;
/** Projects on list form*/
protected List projectsList;
/**PathHolder */
protected PathHolder pathH;
/**Marks wether projectsListhas been set or not*/
private boolean SetConverted = false;
public Person(){
projects= new HashSet();
projectsList = new ArrayList();
createddate = new Long(System.currentTimeMillis());
}
public Person(String fullname,String userName,String password){
this.createddate = new Long(System.currentTimeMillis());
this.handle = userName;
this.password = password;
this.name=fullname;
projects= new HashSet();
projectsList = new ArrayList();
}
/**
* @return Returns the createddate.
*/
public java.lang.Long getCreateddate() {
return createddate;
}
/**
* @param createddate The createddate to set.
*/
public void setCreateddate(java.lang.Long createddate) {
this.createddate = createddate;
}
/**
* @return Returns the handle.
*/
public java.lang.String getHandle() {
return handle;
}
/**
* @param handle The handle to set.
*/
public void setHandle(java.lang.String handle) {
this.handle = handle;
}
/**
* @return Returns the name.
*/
public java.lang.String getName() {
return name;
}
/**
* @param name The name to set.
*/
public void setName(java.lang.String name) {
this.name = name;
}
/**
* @return Returns the password.
*/
public java.lang.String getPassword() {
return password;
}
/**
* @param password The password to set.
*/
public void setPassword(java.lang.String password) {
this.password = password;
}
/**
* @return Returns the projects.
*/
public Set getProjects() {
return projects;
}
/**
* @param projects The projects to set.
*/
public void setProjects(Set projects) {
this.projects = projects;
}
/**
* @return Returns the personId.
*/
public java.lang.Integer getPersonId() {
return personId;
}
/**
* @param personId The personId to set.
*/
public void setPersonId(java.lang.Integer personId) {
this.hashValue = 0;
this.personId = personId;
}
/**
* Implementation of the equals comparison on the basis of equality of the primary key values.
* @param rhs
* @return boolean
*/
public boolean equals(Object rhs)
{
if (rhs == null)
return false;
if (! (rhs instanceof Person))
return false;
Person that = (Person) rhs;
if (this.getPersonId() != null && that.getPersonId() != null)
{
if (! this.getPersonId().equals(that.getPersonId()))
{
return false;
}
}
return true;
}
/**
* Implementation of the hashCode method conforming to the Bloch pattern with
* the exception of array properties (these are very unlikely primary key types).
* @return int
*/
public int hashCode()
{
if (this.hashValue == 0)
{
int result = 17;
int customerIdValue = this.getPersonId() == null ? 0 : this.getPersonId().hashCode();
result = result * 37 + customerIdValue;
this.hashValue = result;
}
return this.hashValue;
}
/**
* get a persons projects by ID
* @param id
* @return null or project
*/
public Project getProjectByID(int id){
Iterator i = this.projects.iterator();
while(i.hasNext()){
Project p = (Project)i.next();
if( p.getProjectId().equals(new Integer(id))) return p;
}
return null;
}
/* (non-Javadoc)
* @see data.ContainsFiles#getContainerName()
*/
public String getContainerName() {
return this.name;
}
/* (non-Javadoc)
* @see data.ContainsFiles#getChilds()
*/
public List getChilds() {
Iterator it = this.getProjects().iterator();
projectsList.removeAll(projectsList);
while(it.hasNext()){
ContainsFiles f =(ContainsFiles) it.next();
this.projectsList.add(f);
f.setfather(this);
}
return projectsList;
}
public ContainsFiles getFather() {
return this;
}
/* (non-Javadoc)
* @see data.ContainsFiles#getUniqueID()
*/
public int getUniqueID() {
return uniqueID;
}
/* (non-Javadoc)
* @see data.ContainsFiles#GetFiles()
*/
public List GetFiles() {
return null;
}
public void setfather(ContainsFiles father) {
//do nothing
}
/**
* @return Returns the pathH.
*/
public PathHolder getPathH() {
return pathH;
}
/**
* @param pathH The pathH to set.
*/
public void setPathH(PathHolder pathH) {
this.pathH = pathH;
}
}