Hibernate join-subclass with child transient getter and setter

时间:2012-09-19 17:38:59

标签: java hibernate jpa-2.0 joined-subclass

我正在尝试在现有结构中添加hibernate继承。所以,我需要添加应该概括3个实体的父类。问题是现在我需要从子进程获取HQL中的继承字段。这样的事情:

@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();
}

当我尝试执行HQL时最终使用此代码

select c from Child c

我有一个SQL错误,上面写着'Unknown column childs.id'

怎么了?

0 个答案:

没有答案