如何在不创建父表的情况下从父模型继承e-bean模型?

时间:2016-12-18 12:52:55

标签: playframework-2.0 ebean

我有一个抽象的父类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 {}

我想创建两个表:userbook_author。不应创建模型Person的表。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

现在,EBean不支持TABLE PER CLASS继承策略。请参阅https://github.com/ebean-orm/ebean/issues/116http://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 {...}