Java Hibernate实体扩展基类,为实体形成的表不';基类中没有属性列
我的sql表只有两列,bookId和title。我应该怎么做才能得到包括作者在内的所有三位成员的表格Java Hibernate实体扩展基类,为实体形成的表不';基类中没有属性列,java,hibernate,Java,Hibernate,我的sql表只有两列,bookId和title。我应该怎么做才能得到包括作者在内的所有三位成员的表格 我的sql表只有两列,bookId和title。我应该如何为所有三个成员(包括作者)获取表。您应该将@MappedSuperclass注释添加到BaseEntity public class BaseEntity { @Column private String author; public BaseEntity(String author) { this.autho
我的sql表只有两列,bookId和title。我应该如何为所有三个成员(包括作者)获取表。您应该将
@MappedSuperclass
注释添加到BaseEntity
public class BaseEntity {
@Column
private String author;
public BaseEntity(String author) {
this.author = author;
}
public String getAuthor() {
return author;
}
}
@Entity
@Table(name = "books")
public class Book extends BaseEntity {
@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name = "increment", strategy = "increment")
private long bookId;
@Column
private String title;
public Book(String author, String title) {
super(author);
this.title = title;
}
public Book() {
super("default");
}
public String getTitle() {
return title;
}
}
@MappedSuperclass
public class BaseEntity {
@Column
private String author;
public BaseEntity(String author) {
this.author = author;
}
public String getAuthor() {
return author;
}
}