Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1. package hu.bois.demo.model;
  2.  
  3. import lombok.*;
  4.  
  5. import javax.persistence.*;
  6. import java.util.Date;
  7. import java.util.List;
  8.  
  9. import hu.bois.demo.model.Package;
  10.  
  11. @Entity
  12. @Table(name = "book")
  13. public class Book {
  14.     @Id
  15.     @GeneratedValue
  16.     @Column(name = "id")
  17.     private Long id;
  18.     @Column(name = "title")
  19.     private @NonNull String title;
  20.     @Column(name = "publisher")
  21.     private @NonNull String publisher;
  22.     @Column(name = "year")
  23.     private Date year;
  24.  
  25.     @OneToMany(fetch = FetchType.LAZY)
  26.     @JoinColumn(name="book_id")
  27.     private List<Package> packages;
  28.  
  29.     public Book(String title, String publisher) {
  30.         this.title = title;
  31.         this.publisher = publisher;
  32.     }
  33.  
  34.     public Book(String title, String publisher, Date year) {
  35.         this.title = title;
  36.         this.publisher = publisher;
  37.         this.year = year;
  38.     }
  39.  
  40.     public Book() {
  41.  
  42.     }
  43.  
  44.     public Book(Long id, Date year, List<Package> packages) {
  45.         this.id = id;
  46.         this.year = year;
  47.         this.packages = packages;
  48.     }
  49.  
  50.     public void setTitle(String title) {
  51.         this.title = title;
  52.     }
  53.  
  54.     public String getTitle() {
  55.         return title;
  56.     }
  57.  
  58.     public Long getId() {
  59.         return id;
  60.     }
  61.  
  62.     public void setId(Long id) {
  63.         this.id = id;
  64.     }
  65.  
  66.     public String getPublisher() {
  67.         return publisher;
  68.     }
  69.  
  70.     public void setPublisher(String publisher) {
  71.         this.publisher = publisher;
  72.     }
  73.  
  74.     public Date getYear() {
  75.         return year;
  76.     }
  77.  
  78.     public void setYear(Date year) {
  79.         this.year = year;
  80.     }
  81.  
  82.     public List<Package> getPackages() {
  83.         return packages;
  84.     }
  85.  
  86.     public void setPackages(List<Package> packages) {
  87.         this.packages = packages;
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement