如何在不创建 parent table 的情况下从 parent 模型继承 e-bean 模型?
How to inherit e-bean models from parent model without creating the parent table?
我有一个摘要parentclassPerson
:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract class Person extends Model {
String firstName;
String lastName;
int gender;
}
和两个child class,先继承:
@Entity
class User extends Person {}
@Entity
class BookAuthor extends Person {}
我想创建两个表:user
和 book_author
。不应创建模型 Person
的 Table。我该怎么做?
TABLE PER CLASS EBean 目前不支持继承策略。参见 https://github.com/ebean-orm/ebean/issues/116 and 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 {...}
我有一个摘要parentclassPerson
:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract class Person extends Model {
String firstName;
String lastName;
int gender;
}
和两个child class,先继承:
@Entity
class User extends Person {}
@Entity
class BookAuthor extends Person {}
我想创建两个表:user
和 book_author
。不应创建模型 Person
的 Table。我该怎么做?
TABLE PER CLASS EBean 目前不支持继承策略。参见 https://github.com/ebean-orm/ebean/issues/116 and 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 {...}