Or you may use  org.apache.commons.lang.builder.HashCodeBuilder class