Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.epolsoft.model;
- import com.epolsoft.dto.user.UserCoachLiteInfo;
- import com.fasterxml.jackson.annotation.JsonIgnore;
- import javax.persistence.*;
- import java.util.ArrayList;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Set;
- @Entity
- public class User {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private Long userId;
- @Column(unique = true, nullable = false, length = 32)
- private String username;
- @Column(nullable = false)
- private String password;
- @Transient
- private String passwordConfirm;
- @Column(nullable = false, length = 50)
- private String firstName;
- @Column(nullable = false, length = 50)
- private String lastName;
- @Column(unique = true, nullable = false, length = 50)
- private String email;
- @ManyToMany
- @JoinTable(name = "User_Role",
- joinColumns = @JoinColumn(name = "userId"),
- inverseJoinColumns = @JoinColumn(name = "roleId"))
- private Set<Role> roles;
- @ManyToMany(fetch = FetchType.LAZY, mappedBy = "students")
- private List<Training> trainings = new ArrayList<Training>();
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "student", cascade = CascadeType.ALL, orphanRemoval = true)
- private List<StudentTaskAssignment> studentTaskAssignments = new ArrayList<>();
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "coach", cascade = CascadeType.ALL, orphanRemoval = true)
- private List<Training> coachsTrainings = new ArrayList<>();
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "coachId", cascade = CascadeType.ALL, orphanRemoval = true)
- private List<Task> coachList = new ArrayList<>();
- public User() {
- }
- public User(UserCoachLiteInfo coach) {
- userId = coach.getUserId();
- username = coach.getUsername();
- firstName = coach.getFirstName();
- lastName = coach.getLastName();
- email = coach.getEmail();
- }
- public Long getUserId() {
- return userId;
- }
- public void setUserId(Long userId) {
- this.userId = userId;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getPasswordConfirm() {
- return passwordConfirm;
- }
- public void setPasswordConfirm(String passwordConfirm) {
- this.passwordConfirm = passwordConfirm;
- }
- public String getFirstName() {
- return firstName;
- }
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
- public String getLastName() {
- return lastName;
- }
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public List<Training> getTrainings() {
- return trainings;
- }
- public void setTrainings(List<Training> trainings) {
- this.trainings = trainings;
- }
- public Set<Role> getRoles() {
- return roles;
- }
- public void setRoles(Set<Role> roles) {
- this.roles = roles;
- }
- public List<StudentTaskAssignment> getStudentTaskAssignments() {
- return studentTaskAssignments;
- }
- public void setStudentTaskAssignments(List<StudentTaskAssignment> studentTaskAssignments) {
- this.studentTaskAssignments = studentTaskAssignments;
- }
- public List<Training> getCoachsTrainings() {
- return coachsTrainings;
- }
- public void setCoachsTrainings(List<Training> coachsTrainings) {
- this.coachsTrainings = coachsTrainings;
- }
- public List<Task> getCoachList() {
- return coachList;
- }
- public void setCoachList(List<Task> coachList) {
- this.coachList = coachList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement