Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Andras Madi-Szabo
Added: May 19, 2020 10:49 AM
Views: 128
Tags: pet vizsga
  1. import com.fasterxml.jackson.annotation.JsonIgnore;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import javax.persistence.CascadeType;
  5. import javax.persistence.Entity;
  6. import javax.persistence.FetchType;
  7. import javax.persistence.GeneratedValue;
  8. import javax.persistence.GenerationType;
  9. import javax.persistence.Id;
  10. import javax.persistence.OneToMany;
  11. import lombok.Getter;
  12. import lombok.Setter;
  13.  
  14. @Getter
  15. @Setter
  16. public class Human {
  17.  
  18.   @Id
  19.   @GeneratedValue(strategy = GenerationType.AUTO)
  20.   private long id;
  21.   private String name;
  22.   @JsonIgnore
  23.   private int age;
  24.   @OneToMany(fetch = FetchType.EAGER, mappedBy = "owner", cascade = CascadeType.ALL)
  25.   private List<Pet> pets = new ArrayList<>();
  26.  
  27.   public Human() {
  28.   }
  29.  
  30.   public Human(String name, int age) {
  31.     this.name = name;
  32.     this.age = age;
  33.   }
  34.  
  35. }