package springrest.model; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty.Access; @Entity @Table(name = "users") public class User implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue private Long id; @Column(nullable = false, unique = true) private String username; @JsonProperty(access = Access.WRITE_ONLY) @Column(nullable = false) private String password; private boolean enabled = true; @ManyToMany @JoinTable(name = "authorities", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id")) Set roles; public User() { 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 boolean isEnabled() { return enabled; } public void setEnabled( boolean enabled ) { this.enabled = enabled; } public Set getRoles() { return roles; } public void setRoles( Set roles ) { this.roles = roles; } }