Advertisement
Bear13th

User.java

Apr 2nd, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. package ru.example.testnew.domain;
  2.  
  3. import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  4. import javax.persistence.*;
  5. import java.util.Set;
  6.  
  7. @EnableWebSecurity
  8. @Table(name = "usr") //Таблица Usr,а не User, чтобы случайно не занять системные названия в postgres
  9. public class User {
  10.     @Id
  11.     @GeneratedValue(strategy = GenerationType.AUTO)
  12.     private Long id;
  13.     private String username;
  14.     private String password;
  15.     private boolean active;
  16.  
  17.     @ElementCollection(targetClass = Role.class, fetch = FetchType.EAGER)
  18.     @CollectionTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"))
  19.     @Enumerated(EnumType.STRING)
  20.     private Set<Role> roles;
  21.  
  22.     public Long getId() {
  23.         return id;
  24.     }
  25.  
  26.     public void setId(Long id) {
  27.         this.id = id;
  28.     }
  29.  
  30.     public String getUsername() {
  31.         return username;
  32.     }
  33.  
  34.     public void setUsername(String username) {
  35.         this.username = username;
  36.     }
  37.  
  38.     public String getPassword() {
  39.         return password;
  40.     }
  41.  
  42.     public void setPassword(String password) {
  43.         this.password = password;
  44.     }
  45.  
  46.     public boolean isActive() {
  47.         return active;
  48.     }
  49.  
  50.     public void setActive(boolean active) {
  51.         this.active = active;
  52.     }
  53.  
  54.     public Set<Role> getRoles() {
  55.         return roles;
  56.     }
  57.  
  58.     public void setRoles(Set<Role> roles) {
  59.         this.roles = roles;
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement