SHARE
TWEET

Untitled

a guest Aug 17th, 2018 220 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package org.junbc.surveyor.model;
  2.  
  3. import java.io.Serializable;
  4. import java.util.HashSet;
  5. import java.util.Set;
  6. import java.util.UUID;
  7.  
  8. import org.hibernate.annotations.GenericGenerator;
  9. import org.hibernate.annotations.Parameter;
  10.  
  11. import javax.persistence.CascadeType;
  12. import javax.persistence.Column;
  13. import javax.persistence.Entity;
  14. import javax.persistence.GeneratedValue;
  15. import javax.persistence.Id;
  16. import javax.persistence.JoinColumn;
  17. import javax.persistence.OneToMany;
  18. import javax.persistence.Table;
  19. import javax.validation.Valid;
  20. import javax.validation.constraints.*;
  21.  
  22. @Entity
  23. @Table(name = "users")
  24. public class User implements Serializable{
  25.  
  26.     /**
  27.      *
  28.      */
  29.     private static final long serialVersionUID = 1L;
  30.  
  31.     @Id
  32.     @GeneratedValue(generator = "UUID")
  33.     @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator", parameters = {
  34.             @Parameter(name = "uuid_gen_strategy_class", value = "org.hibernate.id.uuid.CustomVersionOneStrategy") })
  35.     @Column(name = "id", updatable = false, nullable = false)
  36.     private UUID id = null;
  37.  
  38.     @NotBlank
  39.     @Size(min = 1, max = 100)
  40.     private String name = null;
  41.  
  42.     @NotBlank
  43.     @Column(unique = true)
  44.     @Size(min = 1, max = 100)
  45.     private String email = null;
  46.  
  47.     @NotBlank
  48.     private String password = null;
  49.    
  50.     @NotBlank
  51.     @Size(min = 1, max = 100)
  52.     private String username = null;
  53.    
  54.     @OneToMany(cascade = CascadeType.ALL)
  55.     @JoinColumn(name = "username", referencedColumnName = "username")
  56.     private Set<Authorities> authorities = new HashSet<>();
  57.  
  58.     public User id(UUID id) {
  59.         this.id = id;
  60.         return this;
  61.     }
  62.  
  63.     @NotNull
  64.     @Valid
  65.     public UUID getId() {
  66.         return id;
  67.     }
  68.  
  69.     public void setId(UUID id) {
  70.         this.id = id;
  71.     }
  72.  
  73.     public User name(String name) {
  74.         this.name = name;
  75.         return this;
  76.     }
  77.  
  78.     @NotNull
  79.     public String getName() {
  80.         return name;
  81.     }
  82.  
  83.     public void setName(String name) {
  84.         this.name = name;
  85.     }
  86.  
  87.     public User email(String email) {
  88.         this.email = email;
  89.         return this;
  90.     }
  91.  
  92.     @NotNull
  93.     public String getEmail() {
  94.         return email;
  95.     }
  96.  
  97.     public void setEmail(String email) {
  98.         this.email = email;
  99.     }
  100.  
  101.     public User password(String password) {
  102.         this.password = password;
  103.         return this;
  104.     }
  105.  
  106.     @NotNull
  107.     public String getPassword() {
  108.         return password;
  109.     }
  110.  
  111.     public void setPassword(String password) {
  112.         this.password = password;
  113.     }
  114.  
  115.     public String getUserName() {
  116.         return username;
  117.     }
  118.  
  119.     public void setUserName(String userName) {
  120.         this.username = userName;
  121.     }
  122.  
  123.     public String getUsername() {
  124.         return username;
  125.     }
  126.  
  127.     public void setUsername(String username) {
  128.         this.username = username;
  129.     }
  130.  
  131.     public Set<Authorities> getAuthorities() {
  132.         return authorities;
  133.     }
  134.  
  135.     public void setAuthorities(Set<Authorities> authorities) {
  136.         this.authorities = authorities;
  137.     }
  138.  
  139.  
  140.     @Override
  141.     public String toString() {
  142.         return "User [id=" + id + ", name=" + name + ", email=" + email + ", password=" + password + ", username="
  143.                 + username + ", authorities=" + authorities + "]";
  144.     }
  145. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top