|
Like ids, version properties cannot be defined on a subclass. It must be defined on the top most mapped entity (or on a @MappedSuperclass but that's a different story). That is what the message is saying.
In a class hierarchy, we have the following rule in Hibernate. When two ids match, then the two instances match as well. It would open doors for breaking that if an id could be defined in a subclass. Likewise, you can consider version as part of the general identity of the entity, that's why it has to be defined on the root entity. If you wan to keep your class hierarchy, do something like that
@MappedSuperclass class A {
@Id
@GeneratedValue
private long id;
}
@Entity class B extends A {
@Version
private int modCount;
}
|