title: how to unproxy a hibernate object
body: <p>How can I unproxy a hibernate object, such that polymorphism would be supported?</p>
  
  <p>Consider the following example.  Classes A and B are two hibernate entities.  B has two subtypes C and D.</p>
  
  <pre><code>List&lt;A&gt; resultSet = executeSomeHibernateQuery();
  for(A nextA : resultSet) {
      for(B nextB : nextA.getBAssociations() {
          if(nextB instanceof C) {
              // do something for C
          } else if (nextB instanceof D) {
              // do something for D
          }
      }
  }
  </code></pre>
  
  <p>This code fails to execute either the C or D block, since the B collection has been lazy loaded, and all instances of B are Hibernate proxies.  I'd like a way to unproxy each instance.</p>
  
  <p>Note: I realize the query can be optimized to eagerly fetch all B's.  I'm looking for an alternative.</p>