Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.home.lukasz.SpringChatBackend.models;
- import com.fasterxml.jackson.annotation.JsonIgnore;
- import javax.persistence.*;
- import java.util.HashSet;
- import java.util.Set;
- @Entity
- @Table(name = "shadows")
- public class User {
- @Id
- @Column(name = "id", unique = true, nullable = false)
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
- @Column(name = "username")
- private String username;
- @JsonIgnore
- @Column(name = "password")
- private String password;
- @Column(name = "email")
- private String email;
- @ManyToMany(fetch = FetchType.EAGER)
- @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"),
- inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "role_id"))
- private Set<Role> roles = new HashSet<>();
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- 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 getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public Set<Role> getRoles() {
- return roles;
- }
- public void setRoles(Set<Role> roles) {
- this.roles = roles;
- }
- @Override
- public String toString() {
- return "User{" +
- "id=" + id +
- ", username='" + username + '\'' +
- ", password='" + password + '\'' +
- ", email='" + email + '\'' +
- //", role='" + roles.iterator().next().getRoleName() + '\'' +
- '}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement