Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. @MappedSuperclass
  2. public class BaseEntity {
  3.  
  4. @Id
  5. @GeneratedValue(strategy = GenerationType.IDENTITY)
  6. private Long id;
  7.  
  8. public Long getId() {
  9. return id;
  10. }
  11.  
  12. public void setId(Long id) {
  13. this.id = id;
  14. }
  15.  
  16. @Entity
  17. public class Autor extends BaseEntity {
  18.  
  19. private String nome;
  20. @Column(length = 100)
  21. private String nacionalidade;
  22.  
  23. @OneToMany(mappedBy = "autor")
  24.  
  25. private List<Livro> livros;
  26.  
  27. public String getNome() {
  28. return nome;
  29. }
  30.  
  31. public void setNome(String nome) {
  32. this.nome = nome;
  33. }
  34.  
  35. public String getNacionalidade() {
  36. return nacionalidade;
  37. }
  38.  
  39. public void setNacionalidade(String nacionalidade) {
  40. this.nacionalidade = nacionalidade;
  41. }
  42.  
  43. public List<Livro> getLivros() {
  44. return livros;
  45. }
  46.  
  47. public void setLivros(List<Livro> livros) {
  48. this.livros = livros;
  49. }
  50.  
  51. @Entity
  52. public class Livro extends BaseEntity{
  53.  
  54. private String nome;
  55. private String editora;
  56. private String resumo;
  57.  
  58. @ManyToOne
  59. @JoinColumn(name = "AUTOR_ID")
  60. private Autor autor;
  61.  
  62. public String getNome() {
  63. return nome;
  64. }
  65.  
  66. public void setNome(String nome) {
  67. this.nome = nome;
  68. }
  69.  
  70. public String getEditora() {
  71. return editora;
  72. }
  73.  
  74. public void setEditora(String editora) {
  75. this.editora = editora;
  76. }
  77.  
  78. public String getResumo() {
  79. return resumo;
  80. }
  81.  
  82. public void setResumo(String resumo) {
  83. this.resumo = resumo;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement