Last active
August 19, 2019 03:01
-
-
Save chanwit/c9dc903a1c25477a6a46c153fcbe2500 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sut.sa.cpe.entity; | |
import lombok.*; | |
import javax.persistence.Id; | |
import javax.persistence.JoinColumn; | |
import javax.persistence.OneToMany; | |
import javax.persistence.ManyToOne; | |
import javax.persistence.SequenceGenerator; | |
import javax.persistence.Table; | |
import java.util.Collection; | |
import javax.persistence.CascadeType; | |
import javax.persistence.Column; | |
import javax.persistence.Entity; | |
import javax.persistence.FetchType; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.GenerationType; | |
@Data | |
@Entity | |
@Getter @Setter | |
@NoArgsConstructor | |
@ToString | |
@EqualsAndHashCode | |
@Table(name="EMPLOYEE") | |
public class Employee { | |
@Id | |
@SequenceGenerator(name="EMPLOYEE_SEQ",sequenceName="EMPLOYEE_SEQ") | |
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="EMPLOYEE_SEQ") | |
@Column(name="EMPLOYEE_ID",unique = true, nullable = true) | |
private @NonNull Long id; | |
private @NonNull String name; | |
@OneToMany(fetch = FetchType.EAGER) | |
private Collection<VideoRental> rent; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sut.sa.cpe.entity; | |
import lombok.*; | |
import javax.persistence.Id; | |
import javax.persistence.JoinColumn; | |
import javax.persistence.ManyToOne; | |
import javax.persistence.SequenceGenerator; | |
import javax.persistence.Table; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.GenerationType; | |
import javax.persistence.CascadeType; | |
import javax.persistence.Column; | |
import javax.persistence.Entity; | |
import javax.persistence.FetchType; | |
@Data | |
@Entity | |
@Getter @Setter | |
@NoArgsConstructor | |
@ToString | |
@EqualsAndHashCode | |
@Table(name="VIDEO_RENTAL") | |
public class VideoRental { | |
@Id | |
@SequenceGenerator(name="video_rental_seq",sequenceName="video_rental_seq") | |
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="video_rental_seq") | |
@Column(name = "VIDEO_RENTAL_ID", unique = true, nullable = true) | |
private @NonNull Long id; | |
@Column(name="RENT_DATE") | |
private @NonNull Date rentDate; | |
@ManyToOne(fetch = FetchType.EAGER, targetEntity = Employee.class) | |
@JoinColumn(name = "EMPLOYEE_ID", insertable = true) | |
private Employee createdBy; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment