title: Mapping user to userinfo when there are multiple user type
body: <p>I have a User domain class. It has two user types. One is <code>teacher</code>, other one is <code>student</code>. And it has two fields, one is <code>teacherInfo</code>, the other is <code>studentInfo</code>. Since <code>teacher</code> user has a lot of properties that are different from <code>student</code> user, I cannot combine them as <code>UserInfo</code>. Otherwise there will be a lot of empty fields.</p>
  
  <p>So in hibernate, how should I map the relation. If I use <code>One-to-one</code>, it requires that both <code>teacherInfo</code> and <code>studentInfo</code> cannot be null. Thus, it does not make sense because teacher user should not have a <code>studentInfo</code> mapped with. <code>One-to-many</code> relation solves this problem, but it seems wired. I just cannot make a decision. Thanks.</p>
  
  <pre><code>public class User {
  
      private Integer id;
      private UserType;
      private TeacherInfo teacherInfo;
      private StudentInfo studentInfo;
  }
  </code></pre>