Hash Code Implementation
<p>In relation to this question (<a href="http://stackoverflow.com/questions/1074530/efficient-hashcode-implementation">http://stackoverflow.com/questions/1074530/efficient-hashcode-implementation</a>) I have one more question.</p>

<p>I have a "value" class which instances are persisted in a database. Thus this class's instances all have a unique ID.</p>

<p>As a consequence I implemented the hash code method (and related equals method) simply by returning this id.</p>

<p>When using Eclipse hashcode generator and telling Eclipse to use only the ID attribute for generation I have the following method:</p>

<pre><code>    @Override
    public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + id;
            return result;
    }
</code></pre>

<p>I think simply returning id is more efficient since I KNOW this id is unique. Am I right ?</p>

<p>Thanks in advance </p>
