Is there any reason why shouldn't all my entities be subclasses of one generic ModelEntity object?
@Entity
public class ModelEntity {
@Id Long id;
}
@Subclass
public class User extends ModelEntity {
@Index
String username;
}
The advantages are clear: there is code common to all entities (like id, date, getKey) Can you think of disadvantages?
It can be helpful to have a common base class, but you almost certainly do not want to make it part of a polymorphic entity hierarchy. Don't use
@Subclass
for this purpose; you don't need it: