应用jpa的@MappedSuperclass注意

使用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.
解决:把他加到方法上