title: Spring hibernate - Many to one relationships not working with multiple entities
body: <p>I have created a class call Comment which will have a relationship with two classes: House and User. The house and user entites are already in my database and the house already has a one to many relationship with a user but it won't work with a comment. I keep getting an error 404 whenever I try to reload my server and the comment table is not persisted. Below is my code:</p>
  
  <p>User:</p>
  
  <pre><code>@Entity
  @Table(name = "users")
  public class User {
  
      @NotBlank(groups = { PersistenceValidationGroup.class, FormValidationGroup.class })
      @Size(min = 8, max = 15, groups = { PersistenceValidationGroup.class, FormValidationGroup.class })
      @Pattern(regexp = "^\\w{8,}$", groups = { PersistenceValidationGroup.class, FormValidationGroup.class })
      @Id
      @Column(name = "username")
      private String username;
  
      @NotBlank(groups = { PersistenceValidationGroup.class, FormValidationGroup.class })
      @Pattern(regexp = "^\\S+$", groups = { PersistenceValidationGroup.class, FormValidationGroup.class })
      @Size(min = 8, max = 15, groups = { FormValidationGroup.class })
      private String password;
  
      @Email(groups = { PersistenceValidationGroup.class, FormValidationGroup.class })
      private String email;
  
      @NotBlank(groups = { PersistenceValidationGroup.class, FormValidationGroup.class })
      @Size(min = 8, max = 60, groups = { PersistenceValidationGroup.class, FormValidationGroup.class })
      private String name;
  
      private boolean enabled = false;
      private String authority;
  
      @ManyToOne(cascade = {CascadeType.ALL})
      @JoinColumn(name = "id")
      private House house;
  
      public User() {
      }
  }
  </code></pre>
  
  <p>And my comment:</p>
  
  <pre><code>@Entity
  @Table(name = "comment")
  public class Comment {
  
      @Id
      @GeneratedValue
      @Column(name = "id")
      private int id;
  
      @Lob
      @Column(name = "text")
      private String text;
  
      @Column(name = "date")
      private Date date;
  
      @ManyToOne(optional = false)
      @JoinColumn(name = "username", referencedColumnName = "username")
      private User user;
  
      @ManyToOne(optional = false)
      @JoinColumn(name = "id", referencedColumnName = "id")
      private House house;
  
      public Comment() {
      }
  }
  </code></pre>
  
  <p>Could anyone suggest what I am doing wrong?</p>