title: map two classes to one DB table in Hibernate
body: <p>I have 2 class Class1.java and Class2.java. Both are mapped to Class Table.</p>
  
  <pre><code>@Entity
  @Table(name = "Class")
  public class Class1 {
   String name;
  }
  
  @Entity
  @Table(name = "Class")
  public class Class2 {
    String name;
  }
  </code></pre>
  
  <p>Now when my sessionfactory will be created at that time both the class will be scanned and both will consume memory.</p>
  
  <p>But in my application when it boot up we are deciding at runtime which class will be used in whole application either Class1.java or Class2.java by looking into database. </p>
  
  <p>So I want hibernate to use either of the class Class1.java or Class2.java so that I can save memory. Please help with this issue.</p>