title: (Java/Spring) Accessing class elements using entityType.getJavaType()
body: <p>I created a generic Spring Entiy-Class "TableWithId" which is intended to be inherited by other classes.</p>
  
  <p>Here a snipped from the base class:</p>
  
  <pre><code>@Entity
  @Inheritance(strategy = InheritanceType.JOINED)
  @Table(name = "__base_table")
  public class TableWithId {
      public static String EntityLabel = "All data";
  
      @Id
      @GeneratedValue
      protected Long id;
  </code></pre>
  
  <p>So in my subclasses I am implementing further fields etc. This works very well, It creates, fills and lists content as expected ...</p>
  
  <p>Now I want to be able to get a list of all my entities. This works fine with, well at least to get the names and class-names.</p>
  
  <pre><code>entityManager.getMetamodel().getEntities()
  </code></pre>
  
  <p>Based on the entity name I can also load entities based on user parameters:</p>
  
  <pre><code>entityManager.createQuery("Select t from " + entityName + " t").getResultList();
  </code></pre>
  
  <p>Now there are two things I cannot do:</p>
  
  <p>(1) Access static java properties of my classes, I actually want to access "public static String EntityLabel" at runtime using the java-class returned by "entityType.getJavaType()". In fact I'd like to do something like this:</p>
  
  <pre><code>((TableWithId)  entityType.getJavaType()).EntityLabel
  </code></pre>
  
  <p>(2) For security reasons I also like protecting the system by not allowing the user to make queries on other entities which do not inherit from TableWithId. I'd like to do something like:</p>
  
  <pre><code>entityType.getJavaType() instanceof TableWithId
  </code></pre>
  
  <p>Any help is appreciated :)</p>