package fr.plil.sio.web.mvc; import com.fasterxml.jackson.annotation.JsonManagedReference; import java.util.ArrayList; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import javax.persistence.*; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.TreeSet; @Entity @Table(name = "USER_T") public class User implements UserDetails { @Id @Column(name = "USER_ID") @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Column(name = "USERNAME_F") private String username; @Column(name = "PASSWORD_F") private String password; @OneToMany(mappedBy="holderOfDebt",cascade = CascadeType.REMOVE) private List dettes = new ArrayList(); public List getDettes() { return dettes; } public void setDettes(List dettes) { this.dettes = dettes; } @ManyToMany(mappedBy = "users", fetch = FetchType.EAGER) @JsonManagedReference private Set roles = new TreeSet<>(); public Set getRoles() { return roles; } public void setRoles(Set roles) { this.roles = roles; } @Override public Collection getAuthorities() { return roles; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } @Override public boolean isAccountNonExpired() { return true; } @Override public boolean isAccountNonLocked() { return true; } @Override public boolean isCredentialsNonExpired() { return true; } @Override public boolean isEnabled() { return true; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }