title: Generic way to get JPA entity version
body: <p>I have an unknown JPA entity and need to know it's version. I could not find a way to do this generically.</p>
  
  <p>I tried the metamodel, but don't know what to pass to getVersion() method:</p>
  
  <pre><code>Object entity = ...;
  Metamodel metamodel = entityManager.getMetamodel();
  IdentifiableType&lt;?&gt; metaClass = 
      (IdentifiableType&lt;?&gt;)metamodel.managedType(entity.getClass());
  metaClass.getVersion(&lt;what to put here?&gt;);
  </code></pre>
  
  <p>Same pattern is used in <code>metaClass.getId()</code>, but there is a complementary method <code>getIdType()</code> -- <code>getVersionType()</code> is missing.</p>
  
  <p>Secondly, there is <code>entityManagerFactory.getPersistenceUnitUtil().getIdentifier(entity)</code> method, but not <code>getVersion(entity)</code> method.</p>
  
  <p>Is there some way to get version from an unknown entity?</p>