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;
}
}
我的 sql 表只有两列:bookId 和 title。我应该怎么做才能获得包括作者在内的所有三个成员的桌子。
我的 sql 表只有两列:bookId 和 title。我应该怎么做才能获得包括作者在内的所有三个成员的桌子。
你应该添加@MappedSuperclass
注释到BaseEntity
@MappedSuperclass
public class BaseEntity {
@Column
private String author;
public BaseEntity(String author) {
this.author = author;
}
public String getAuthor() {
return author;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)