首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

应用jpa的@MappedSuperclass注意

2012-11-07 
使用jpa的@MappedSuperclass注意@MappedSuperclasspublic abstract class ID{@Id@GeneratedValueprivate l

使用jpa的@MappedSuperclass注意

@MappedSuperclasspublic abstract class ID  {    @Id    @GeneratedValue    private long id;    public long getId() {        return id;    }    public void setId(long id) {        this.id = id;    }}

在用上面的类作为Id继承时,子类会出现 Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.Set 异常。大概因为
  @Id
  @GeneratedValue
加在了字段上,子类会找不到子类继承的Id.
解决:把他加到方法上

热点排行