title: Hibernate/JPA equals() and hashCode() with Lazy loaded Business Identifier
body: <p>I'm wondering how to write a correct equals() and hashCode() for Hibernate Entities which have a Lazy Loaded ManyToOne relation to another Entity which is important as a business key. Note, that I already read <a href="http://community.jboss.org/wiki/EqualsandHashCode">the Hibernate documentation on this topic</a> and I know I must/should not use the object id.</p>
  
  <p>To clarify, here an example:</p>
  
  <pre><code>public class BusinessEntity implements Serializable
  {
      //for simplicity, here just the important part
      private String s;
  
      @ManyToOne(fetch= FetchType.LAZY )
      private ImportantEntity anotherEntity;
  
      @Override
      public boolean equals( Object obj )
      {
         //Here I would like to call something like
         // (obj.getAnotherEntity.getName.equals(getAnotherEntity.getName) &amp;&amp; obj.getS().equals(getS());
  
         return true;
      }
  }
  </code></pre>
  
  <p>Of course this is just a simplified example. But I hope I could explain my scenario. Has someone tried something like that before? I did not find anything regarding to this topic.</p>