title: Hibernate how to discriminate in joined-subclass
body: <p>Supposing I have the following case of Entity model and using Hibernate 3.6:</p>
  
  <pre><code>Person
      |__ Student
              |__ SchoolBoy
              |__ CollegeStudent
  </code></pre>
  
  <p>The tables I have in my DB are <strong>tperson</strong> and <strong>tstudent</strong>. As I'm using hibernate mapping files, I declare it as below into my Person entity definition:</p>
  
  <pre><code>&lt;joined-subclass name="Student" table="tstudent"&gt;
      &lt;key column="id_person" /&gt;
  &lt;/joined-subclass&gt;
  </code></pre>
  
  <p>Being SchoolBoy similar to CollegeStudent, I want to use the same table for both (tstudent), having a <strong>student-type</strong> discriminator column, while I keep both of the classes. My problem is that Hibernate doesn't seem to allow discriminator columns once you're into a joined-subclass. </p>
  
  <p>Is there a workaround for that?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>That's what I have right now:</p>
  
  <pre><code>&lt;class name="Person"&gt;
      &lt;id name="Id" column="id" type="integer"&gt;
          &lt;generator class="increment" /&gt;
      &lt;/id&gt;
      &lt;joined-subclass name="Student" table="tstudent"&gt;
          &lt;key column="id_person" /&gt;
          &lt;joined-subclass name="SchoolBoy" table="tschoolboy"&gt;
              &lt;key column="id_person" /&gt;
          &lt;/joined-subclass&gt;
          &lt;joined-subclass name="CollegeStudent" table="tcollegestudent"&gt;
              &lt;key column="id_person" /&gt;
          &lt;/joined-subclass&gt;
      &lt;/joined-subclass&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>That's what I would like to have in the join part of the mapping:</p>
  
  <pre><code>&lt;joined-subclass name="Student" table="tstudent"&gt;
      &lt;key column="id_person" /&gt;
      &lt;discriminator column="student_type" /&gt;
      &lt;subclass name="SchoolBoy" discriminator-value="SCHOOL_BOY" /&gt;
      &lt;subclass name="CollegeStudent" discriminator-value="COLLEGE_STUDENT" /&gt;
  &lt;/joined-subclass&gt;
  </code></pre>