title: Hibernate.getClass(Object proxy) returns Class, how to get Class<T> instead?
body: <p>My Problem is with Hibernates <code>getClass(Object proxy)</code> method which according to documentation does help me</p>
  
  <blockquote>
    <p>[to g]et the true, underlying class of a proxied persistent class.   </p>
  </blockquote>
  
  <p><a href="https://docs.jboss.org/hibernate/core/4.2/javadocs/org/hibernate/Hibernate.html#getClass(java.lang.Object)" rel="nofollow noreferrer">https://docs.jboss.org/hibernate/core/4.2/javadocs/org/hibernate/Hibernate.html#getClass(java.lang.Object)</a></p>
  
  <p>The <code>getClass(Object proxy)</code> methods returns a <code>Class</code> object. The <code>getClass()</code> method of objects however returns on the other hand a <code>Class&lt;?&gt;</code> object. </p>
  
  <p><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--" rel="nofollow noreferrer">https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--</a></p>
  
  <p>This difference composes a difficulty to me when working with methods that employ Java generics like this</p>
  
  <pre><code>public &lt;T`getClass(Object proxy)`&gt; T doWithGenericObject(Class&lt;T&gt; clazz)
  </code></pre>
  
  <p>which cannot be used with the information that <code>Hibernate.org</code> provides me via its <code>static Class Hibernate.getClass(Object proxy)</code> method.</p>
  
  <p>Is there:</p>
  
  <ol>
  <li>a way to get the <code>Class&lt;T&gt;</code> from hibernate? or </li>
  <li>a way to convert <code>Class</code> to <code>Class&lt;T&gt;</code>? or </li>
  <li>prevent Hibernate to retrieve a Proxy in the first place?</li>
  </ol>