I'm attempting to create a base class for a set of entities to reduce coding effort and duplication. My thought is that the base class has the common meta-data fields, and the child classes deal with their unique attributes.
My base class:
@MappedSuperclass
public abstract class FinanceEntityBean {
protected Long id;
@Version
private long version;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
}
The first entity:
@Entity
@Table(name = "tag")
public class Tag extends FinanceEntityBean {
}
I've written tests using this code to do CRUD functions on the Tag entity, and they are all working fine.
My question is - why does Eclipse (Indigo) insist that Tag
has an error:
The entity has no primary key attribute defined
I've changed that to a warning for now so my code will compile, but I'm curious why Eclipse isn't happy, and if I've misunderstood something.
Is this valid JPA 2.0 code? Hibernate 4.1.5 is my JPA provider.