title: Hibernate not setting foreign key
body: <p>I'm trying to learn Hibernate with this simple example but I'm having so trouble with the foreign key which remains "null" in the database.</p>
  
  <pre><code>@Entity
  @Table(name = "tb1")
  public class Track {
      @Id
      @GeneratedValue(strategy= GenerationType.IDENTITY)
      @Column(name="id_tb1", unique= true)
      private int id_tb1;
      @Column(name = "title")
      private String title;
      @ManyToOne
      @JoinColumn(name="id_tb2")
      private tb2 cd;
  </code></pre>
  
  <p>And this is the second class</p>
  
  <pre><code>@Entity
  @Table(name = "tb2")
  public class CD {
  
      @Id
      @GeneratedValue(strategy= GenerationType.IDENTITY)
      @Column(name="id_tb2", unique = true)
      private int id_tb2;
      @Column(name="title")
      private String title;
      @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL,mappedBy = "cd")
      private List&lt;tb1&gt; tracks = new ArrayList&lt;tb1&gt;();
  </code></pre>
  
  <p>I save like this:</p>
  
  <pre><code>SessionFactory factory = new Configuration().configure("/resources/hibernate.cfg.xml").buildSessionFactory();
                  Session session1 = factory.openSession();
                  session1.beginTransaction();
                  session1.save(tb2);
                  session1.getTransaction().commit();
  </code></pre>
  
  <p>but when Isavethe id_tb2 (in the table tb1) is not set and it remains null. What I'm missing?</p>