Advertisement
SensaBG

Untitled

Dec 9th, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. package sofuni.exam.models.entity;
  2.  
  3. import jakarta.persistence.*;
  4. import lombok.Getter;
  5. import lombok.Setter;
  6. import sofuni.exam.models.enums.Type;
  7.  
  8. import java.util.List;
  9. import java.util.Set;
  10.  
  11. @Getter
  12. @Setter
  13. @Entity
  14. @Table(name = "planets")
  15. public class Planet extends BaseEntity {
  16.  
  17.     @Column(nullable = false, unique = true)
  18.     private String name;
  19.  
  20.     @Column(nullable = false)
  21.     private int diameter;
  22.  
  23.     @Column(name = "distance_from_sun",nullable = false)
  24.     private Long distanceFromSun;
  25.  
  26.     @Column(name = "orbital_period", nullable = false)
  27.     private Double orbitalPeriod;
  28.  
  29.     @Enumerated(EnumType.STRING)
  30.     @Column(nullable = false)
  31.     private Type type;
  32.  
  33.     @OneToMany(mappedBy = "planet")
  34.     private List<Moon> moons;
  35. }
  36.  
  37. =============================================
  38.  
  39. package sofuni.exam.models.entity;
  40.  
  41. import jakarta.persistence.*;
  42. import lombok.Getter;
  43. import lombok.Setter;
  44.  
  45. import java.util.List;
  46.  
  47. @Getter
  48. @Setter
  49. @Entity
  50. @Table(name = "discoverers")
  51. public class Discoverer extends BaseEntity {
  52.  
  53.     @Column(name = "first_name", nullable = false)
  54.     private String firstName;
  55.  
  56.     @Column(name = "last_name",nullable = false)
  57.     private String lastName;
  58.  
  59.     @Column(nullable = false)
  60.     private String nationality;
  61.  
  62.     @Column
  63.     private String occupation;
  64.  
  65.     @OneToMany(mappedBy = "discoverer")
  66.     private List<Moon> moons;
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement