Hi, I need help with inheritance in JPA
I will illustrate my problem with an example:
Supose we have an Animal class and a Cat class.
@Entity
@Table(name = "animal")
@DiscriminatorColumn(name="animal_type",columnDefinition="Integer",length=11)
public class Animal implements Serializable{
@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
@Column(name = "animal_id", nullable = false)
private Long id;
...
}
@Entity
@Table(name = "cat")
@DiscriminatorValue("1")
@AttributeOverride(name="id",column=@Column(name="cat_id"))
public class Cat extends Animal {
...
}
As the example shows, i want to use a different name for my id column in the cat table
But then when i try to perform a polymorphic query asking for all the Animal instances i get an error. It is like the query cannot handle the different field names according the animal instance.
Am i doing this right? Thanks in advance.