我有一个抽象的父类Person
:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract class Person extends Model {
String firstName;
String lastName;
int gender;
}
和两个继承第一个的子类:
@Entity
class User extends Person {}
@Entity
class BookAuthor extends Person {}
我想创建两个表:user
和book_author
。不应创建模型Person
的表。我怎么能这样做?
答案 0 :(得分:1)
现在,EBean不支持TABLE PER CLASS继承策略。请参阅https://github.com/ebean-orm/ebean/issues/116和http://ebean-orm.github.io/docs/mapping/jpa/
您可以使用@MappedSuperclass注释。
@MappedSuperclass
abstract class Person extends Model {...}
@Entity
public class User extends Person {...}
@Entity
public class BookAuthor extends Person {...}