title: Spring jpa data jpa composite with 3 primary key using IdClass
body: <p>I have many to many relation between user and comment. It works but in a way that the user can only make one comment. I need to add another generated id that makes the key unique. </p>
  
  <p><strong>The Comment Class</strong> </p>
  
  <pre><code> @Entity
  @IdClass(CommentPK.class)
  public class Comment {
      @Id
      private Long id;
  
  
      @Id
      @ManyToOne
      @JoinColumn(name = "gameID" ,referencedColumnName = "id")
      private Game game;
  
      @Id
      @ManyToOne
      @JoinColumn(name = "userID",referencedColumnName = "id")
      private User user;
  
      private String Text;
  
      public Comment() {
          super();
          this.id = null;
          this.game = null;
          this.user = null;
          Text = null;
      }
      public Comment(Game game, User user, String text) {
          this();
          this.id = null;
          this.game = game;
          this.user = user;
          Text = text;
      }
      public Comment(Game game, String text) {
          this();
          this.id = null;
          this.game = game;
          this.Text = text;
      } }//setters and getters
  </code></pre>
  
  <p><strong>The CommentPK</strong> </p>
  
  <pre><code>public class CommentPK implements Serializable {
  @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      private Long game;
  
      private Long user; }//setters and getters
  </code></pre>
  
  <p><strong>The Error not all of it is really big</strong> </p>
  
  <pre><code>Can not set java.lang.Long field guru.springframework.domain.CommentPK.game to guru.springframework.domain.TF_Game
  </code></pre>
  
  <p>It was working fine without the generated id.</p>