Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.d288.mwise60.entities;
- import jakarta.persistence.*;
- import lombok.Data;
- import lombok.Getter;
- import lombok.Setter;
- import org.hibernate.annotations.CreationTimestamp;
- import org.hibernate.annotations.UpdateTimestamp;
- import java.util.Date;
- import java.util.HashSet;
- import java.util.Set;
- @Entity
- @Table(name = "countries")
- @Getter
- @Setter
- public class Country {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "country_id")
- private Long id; // SQL refers to it as "country_id"
- // temp workaround for Division class not accessing the lombok getters
- public Long getId() {
- return id;
- }
- @Column(name = "country")
- private String country_name; // SQL refers to it as "country"
- @CreationTimestamp // hibernate manages grabbing time
- @Column(name = "create_date")
- private Date create_date;
- @UpdateTimestamp
- @Column(name = "last_update") // hibernate manages grabbing time
- private Date last_update;
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "country") // SQL refers to it as "country_id"
- private Set<Division> divisions = new HashSet<>();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement