title: Hibernate, fetch, HQL and hashCode()
body: <p>I have a HQL query something ala'</p>
  
  <pre><code>SELECT myclass 
  FROM 
      MyClass myclass JOIN FETCH 
      myclass.anotherset sub JOIN FETCH 
      sub.yetanotherset
  ...
  </code></pre>
  
  <p>So, class MyClass has a property "anotherset" , which is a set containing instance of another class, lets call it MyClassTwo. And, class MyClassTwo has a property yetanotherset which is a set of a third type of class (with no further associations on it).</p>
  
  <p>In this scenario, I'm having trouble with the hashCode implementation. Basically, the hashCode implementation of MyClassTwo, uses the "yetanotherset" property, and on the exact line it accesses the yetanothertest property, it fails with a LazyInitializationException. </p>
  
  <pre><code>org.hibernate.LazyInitializationException: illegal access to loading collection 
  </code></pre>
  
  <p>I'm guessing, this is because the data from "yetanotherset" hasn't been fetched yet, but how do I fix this? I don't particularly like the idea of dumbing down the hashCode to ignore the property. </p>
  
  <p>Additional question, does HQL ignore fetch=FetchType.EAGER as defined in XML or annotations, it seems like it does. But I cant verify this anywhere.</p>