title: How do I use the jpa/hibernate annotation mapping to Set<Entity> and the Entity is composite primary key
body: <pre><code>@Data
  @NoArgsConstructor
  @AllArgsConstructor
  @Entity(name = "users")
  @ToString
  @Table(name = "users")
  @Embeddable
  public class User implements UserDetails{
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "id",unique=true)
      private Long id;
      @OneToMany
      @Cascade({CascadeType.ALL })
      @JoinTable(name = "users_authorities")
      private Set&lt;SimpleGrantedAuthority&gt; authorities;
  }
  </code></pre>
  
  <p>This is my <code>User.java</code>,and have a porperty <code>private Set&lt;SimpleGrantedAuthority&gt; authorities</code>. I want use jpa/hibernate mapping to another Entity <code>SimpleGrantedAuthority</code>.</p>
  
  <pre><code>@Data
  @Entity(name = "authorities")
  @Embeddable
  @Table(name = "authorities", uniqueConstraints={@UniqueConstraint(columnNames={"authority","username"})})
  class SimpleGrantedAuthority implements GrantedAuthority {
      private Long id;
      @Column(name = "authority")
      private String authority;
      @Column(name = "username")
      private String username;
  }
  </code></pre>
  
  <p>This is <code>SimpleGrantedAuthority .java</code>,How do I write the correct annotation to map <code>Set&lt;SimpleGrantedAuthority&gt; authorities;</code> to <code>SimpleGrantedAuthority.java</code>above <code>private Set&lt;SimpleGrantedAuthority&gt; authorities;</code></p>
  
  <pre><code>Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.as.backend.antscience.entity.SimpleGrantedAuthority
  </code></pre>