title: Multiple users with Spring Security
body: <p>I have 4 different type of users. Every type have own role and additional attributes. 
  User is parent, and 3 inheritors.</p>
  
  <p>Also I use Spring Data. </p>
  
  <p>In which way I can implement UserDetailsService to use 4 different types of users?</p>
  
  <p>Now I have:</p>
  
  <pre><code>@Inheritance(strategy = InheritanceType.JOINED)
  public class User implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue
      private Long id;
      private String username;
      private String password;
      private String email;
      @ManyToMany
      @JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
      private Set&lt;Role&gt; roles;
  
  }
  </code></pre>
  
  <p>And </p>
  
  <pre><code>public class Employee extends User implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
  
      private String fullName;
      @ManyToMany(mappedBy = "employees")
      private Set&lt;Project&gt; projects;
      @OneToMany(mappedBy = "employee")
      private Set&lt;Task&gt; tasks;
  
  }
  </code></pre>
  
  <p>And other.</p>