Hibernate single-table inheritance and multiple @ManyToOne
<p>I have the following class setup, with SINGLE_TABLE inheritance:</p>

<pre><code>@Entity
@Table(name = "ANIMALS")
@DiscriminatorColumn(name="DISCR")
@DiscriminatorValue("Animal")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Animal {
    private String discr;
    ...
}

@Entity
@Table(name = "ANIMALS")
@DiscriminatorValue("Cat")
public class Cat extends Animal {
    private String discr;
    ...
}

@Entity
@Table(name = "PERSONS")
public class Person {
    @ManyToOne
    @JoinColumn(name = "ANIMAL_ID", referencedColumnName = "ID")
    private Animal animal;

    @ManyToOne
    @JoinColumn(name = "ANIMAL_ID", referencedColumnName = "ID")
    private Cat cat;
    ...
}
</code></pre>

<p>In the <code>Person</code> class, I have two <code>@ManyToOne</code> relationships to the <code>Animal</code> and <code>Cat</code> classes. I'd like Hibernate to map to the correct field (<code>animal</code> or <code>cat</code>) according to the discriminator. With this code, Hibernate throws errors when trying to map an <code>Animal</code> record to a <code>Cat</code> object.</p>