I'm trying to add hibernate inheritance in existing structure. So, I need to add parent class which should generalize 3 entities. The problem is that now I need to get inherited fields in HQL from child. Something like this:
@Table(name="parents")
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Parent{
@Id
Long id;
//additional code with protected getter and setter for id
}
@Table(name="childs")
@Entity
@PrimaryKeyJoinColumn(name="id")
public class Child extends Parent{
@Transient
public void setChildId(Long id){
super.setId(id);
}
@Transient
public Long getChildId(){
return super.getId();
}
Finaly with this code when I'm trying to execute HQL like
select c from Child c
I have an SQL error which says 'Unknown column childs.id'
What's wrong?