Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. @Entity
  2. @Table(name = "user")
  3. public class User {
  4.  
  5. @Id
  6. @GeneratedValue(strategy = GenerationType.AUTO)
  7. private Long id;
  8.  
  9. @NotBlank
  10. @Column(name = "user_name", unique = true)
  11. private String userName;
  12.  
  13. @Column(name = "password")
  14. private String password;
  15.  
  16. @Email
  17. @NotBlank
  18. @Column(name = "email")
  19. private String email;
  20.  
  21. @Column(name = "locked")
  22. private boolean locked;
  23.  
  24. @Enumerated(EnumType.STRING)
  25. @Column(name = "role")
  26. private Role role;
  27.  
  28. @ManyToOne(optional = true, fetch = FetchType.LAZY)
  29. @JoinColumn(name = "dealer_id", referencedColumnName = "id")
  30. private Dealer delaer;
  31.  
  32. @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
  33. private List<EventLog> events;
  34.  
  35. protected User() {
  36. this.events = new ArrayList<>();
  37. }
  38.  
  39. /**
  40. * Constructor for User.
  41. *
  42. * @param userName Username of the user
  43. * @param password Encrypted password
  44. * @param email Email of the user
  45. * @param locked Determines if user account if locked or not
  46. */
  47. public User(@Nonnull String userName, @Nonnull String password, @Nonnull String email, boolean locked, @Nonnull Role role) {
  48.  
  49. this();
  50.  
  51. Preconditions.checkArgument(userName != null);
  52. Preconditions.checkArgument(password != null);
  53. Preconditions.checkArgument(email != null);
  54. Preconditions.checkArgument(role != null);
  55.  
  56. this.userName = userName;
  57. this.password = password;
  58. this.email = email;
  59. this.locked = locked;
  60. this.role = role;
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement