Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package softuniBlog.entity;
- import javax.jws.soap.SOAPBinding;
- import javax.persistence.*;
- import java.util.HashSet;
- import java.util.Set;
- @Entity
- @Table(name = "users")
- public class User {
- private Integer id;
- private String email;
- private String fullName;
- private String password;
- private Set<Role> roles;
- private Set<Images> images;
- private Set<User> followingUser;
- private String profilePicture;
- public User(String email, String fullName, String password) {
- this.email = email;
- this.password = password;
- this.fullName = fullName;
- this.roles = new HashSet<>();
- this.images = new HashSet<>();
- this.followingUser = new HashSet<>();
- }
- public User() {
- }
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- public Integer getId() {
- return id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- @Column(name = "email", unique = true, nullable = false)
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- @Column(name = "fullName", nullable = false)
- public String getFullName() {
- return fullName;
- }
- public void setFullName(String fullName) {
- this.fullName = fullName;
- }
- @Column(name = "password", length = 60, nullable = false)
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- @ManyToMany(fetch = FetchType.EAGER)
- @JoinTable(name = "users_roles")
- public Set<Role> getRoles() {
- return roles;
- }
- public void setRoles(Set<Role> roles) {
- this.roles = roles;
- }
- public void addRole(Role role) {
- this.roles.add(role);
- }
- @OneToMany(mappedBy = "user")
- public Set<Images> getImages() {
- return images;
- }
- public void setImages(Set<Images> images) {
- this.images = images;
- }
- @ManyToMany(cascade = CascadeType.ALL)
- @JoinTable(name = "user_following", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "following_id", referencedColumnName = "id"))
- public Set<User> getFollowingUser() {
- return followingUser;
- }
- public void setFollowingUser(Set<User> followingUser) {
- this.followingUser = followingUser;
- }
- public void addFollow(User user) {
- this.followingUser.add(user);
- }
- @Column(name = "profilePicturePath", nullable = false)
- public String getProfilePicture() {
- return profilePicture;
- }
- public void setProfilePicture(String profilePicture) {
- this.profilePicture = profilePicture;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement