Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @MappedSuperclass
- public class BaseEntity {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- @Entity
- public class Autor extends BaseEntity {
- private String nome;
- @Column(length = 100)
- private String nacionalidade;
- @OneToMany(mappedBy = "autor")
- private List<Livro> livros;
- public String getNome() {
- return nome;
- }
- public void setNome(String nome) {
- this.nome = nome;
- }
- public String getNacionalidade() {
- return nacionalidade;
- }
- public void setNacionalidade(String nacionalidade) {
- this.nacionalidade = nacionalidade;
- }
- public List<Livro> getLivros() {
- return livros;
- }
- public void setLivros(List<Livro> livros) {
- this.livros = livros;
- }
- @Entity
- public class Livro extends BaseEntity{
- private String nome;
- private String editora;
- private String resumo;
- @ManyToOne
- @JoinColumn(name = "AUTOR_ID")
- private Autor autor;
- public String getNome() {
- return nome;
- }
- public void setNome(String nome) {
- this.nome = nome;
- }
- public String getEditora() {
- return editora;
- }
- public void setEditora(String editora) {
- this.editora = editora;
- }
- public String getResumo() {
- return resumo;
- }
- public void setResumo(String resumo) {
- this.resumo = resumo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement