Why is @DiscriminatorColumn ignored when using @JoinTable?
<p>Suppose I have the following tables:</p>

<pre><code> ______________________
|       LAWSUIT        |
|______________________|
| ID                   |
| TITLE                |
|______________________|
                        \
                         \
                          \
                             ______________________
                            | PERSONS_IN_THE_CASE  |
                            |______________________|
                            | ID_LAWSUIT           |
                            | ID_PERSON            |
                            |______________________|
                          /
                         /
                        /
 ______________________
|        PERSON        |
|______________________|
| ID                   |
| NAME                 |
| TYPE                 | TYPE values = "Plantiff, Defendant, Lawyer, Judge, ..."
|______________________|
</code></pre>

<p><sub>(I know that normalizing the database I could have a table for each person type, but let's stick to the actual structure)</sub></p>

<p>I've subclassed the different <em>Persons</em> with JPA (2.0) as follows:</p>



<pre class="lang-java prettyprint-override"><code>@Entity
@Table(name="PERSON")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE")
public abstract class Person {
</code></pre>



<pre class="lang-java prettyprint-override"><code>@Entity
@DiscriminatorValue("Plantiff")
public class Plantiff extends Person {  
</code></pre>



<pre class="lang-java prettyprint-override"><code>@Entity
@DiscriminatorValue("Defendant")
public class Defendant extends Person { 
</code></pre>



<pre class="lang-java prettyprint-override"><code>@Entity
@DiscriminatorValue("Lawyer")
public class Lawyer extends Person {    
</code></pre>

<p>This works correctly, because I can query a single category and the filter is automatic, eg <code>findAll</code> on <em>Plantiff</em> will get all the <em>Plantiffs</em> of all times.</p>

<p>Now I'm trying to link them to the <em>Lawsuit</em> through the <code>PERSONS_IN_THE_CASE</code>  @JoinTable:</p>

<pre class="lang-java prettyprint-override"><code>@Entity
@Table(name="LAWSUIT")
public class Lawsuit {

    @Id
    Long id;

    String title;

    @OneToMany
    @JoinTable(name="PERSONS_IN_THE_CASE",
               joinColumns=@JoinColumn(name="ID_LAWSUIT", referencedColumnName="ID"),
        inverseJoinColumns=@JoinColumn(name="ID_PERSON",  referencedColumnName="ID"))
    Plantiff plantiff;


    @ManyToMany
    @JoinTable(name="PERSONS_IN_THE_CASE",
               joinColumns=@JoinColumn(name="ID_LAWSUIT", referencedColumnName="ID"),
        inverseJoinColumns=@JoinColumn(name="ID_PERSON",  referencedColumnName="ID"))
    Set&lt;Defendant&gt; defendants;

    ...
}
</code></pre>

<p>Here is where things break: <strong>the <code>@DiscriminatorValue</code> is not applied</strong>, it seems to be completely bypassed by the <code>@JoinTable</code>. </p>

<p><strong>In fact, the <code>Set&lt;Defendant&gt;</code> does not contain only the <em>defendants</em>, but every <em>person</em> in the case</strong> (every record in the <code>PERSONS_IN_THE_CASE</code> relational table. For example, if I have a <em>Plantiff</em>, a <em>Judge</em>, two <em>Defendants</em> and two <em>Lawyers</em>, the above <code>Set&lt;Defendant&gt;</code> will contain 6 persons instead of 2).</p>

<p><strong>How can I make the <code>@DiscriminatorValue</code> working through the <code>@JoinTable</code> binding ?</strong></p>

<p><strong>EDIT:</strong> I'm using Hibernate 3.6.6.Final, and (although I always try to avoid it) <strong>I'm open to vendor-specific solutions</strong>, like <strike><code>@ForceDiscriminator</code></strike>(deprecated), <code>@DiscriminatorOptions(force=true)</code> and so on. I've obviosuly tried before asking (without being able to make it work, though).</p>