Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package th.co.geniustree.intenship.advisor.model; import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.ManyToMany; import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Temporal; import org.hibernate.validator.constraints.NotBlank; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; /** * * @author Account */ @Entity @Table(name = "ACCOUNT") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Account implements Serializable, UserDetails { @Id @SequenceGenerator(name = "ACCOUNT", sequenceName = "ACCOUNT_SEQ", allocationSize = 1) @GeneratedValue(generator = "ACCOUNT", strategy = GenerationType.SEQUENCE) private Integer id; @NotBlank(message = "please input email") private String email; private String password; private String filePic; private String idStudent; private String idCard; private String name; @Temporal(javax.persistence.TemporalType.DATE) private Date bDate; private Integer age; private String mobile; private String address; private boolean enable = true; @Column(name = "DTYPE", insertable = false, updatable = false) private String dtype; @ManyToMany private List<Authority> roles; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getFilePic() { return filePic; } public void setFilePic(String filePic) { this.filePic = filePic; } public String getIdStudent() { return idStudent; } public void setIdStudent(String idStudent) { this.idStudent = idStudent; } public String getIdCard() { return idCard; } public void setIdCard(String idCard) { this.idCard = idCard; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Date getbDate() { return bDate; } public void setbDate(Date bDate) { this.bDate = bDate; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public String getMobile() { return mobile; } public void setMobile(String mobile) { this.mobile = mobile; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public boolean isEnable() { return enable; } public void setEnable(boolean enable) { this.enable = enable; } public List<Authority> getRoles() { return roles; } public void setRoles(List<Authority> roles) { this.roles = roles; } public String getDtype() { return dtype; } public void setDtype(String dtype) { this.dtype = dtype; } @Override public int hashCode() { int hash = 7; hash = 43 * hash + Objects.hashCode(this.id); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Account other = (Account) obj; if (!Objects.equals(this.id, other.id)) { return false; } return true; } @Override public String getUsername() { return email; } @Override public boolean isAccountNonExpired() { return true; } @Override public boolean isAccountNonLocked() { return true; } @Override public boolean isCredentialsNonExpired() { return true; } @Override public boolean isEnabled() { return enable; } @Override public Collection<? extends GrantedAuthority> getAuthorities() { return Collections.emptySet(); } }