title: Hibernate is inserting null values in foreign key field
body: <p>I have 2 simple domain objects as follows..with MYSQL DB.</p>
  
  <pre><code>@Entity
  @Table(name="Product")
  public class Product {
      @Id
      @Column(name="productId")
      @GeneratedValue
      protected int productId;
      @Column(name="Product_Name")
      protected String name;
      @OneToMany(cascade = javax.persistence.CascadeType.ALL,mappedBy="product")
      protected List&lt;ProductOption&gt; productoption = new ArrayList&lt;ProductOption&gt;();
  </code></pre>
  
  <p>and second object</p>
  
  <pre><code>@Entity
  @Table(name="ProductOption")
  public class ProductOption{
  
  
      /**
       * 
       */
  
      @Id
      @Column(name="product_option_id")
      @GeneratedValue
      protected int productOptionId;
  
  
      //@JoinColumn(name="productId")
      @ManyToOne()
      protected Product product;      
  
      @Column(name="ProductTopping")
      private String topping;
  </code></pre>
  
  <p>and my main method.</p>
  
  <pre><code>public class Createschema {
  
      public static void main(String[] args) {
  
          Product product = new Product();
          product.setName("Coffee");
  
          ProductOption po2 = new ProductOption();
          po2.setTopping("barbeque");
          ProductOption po = new ProductOption();
          po.setTopping("whipcream");
          ProductOption po1 = new ProductOption();
          po1.setTopping("honeymustard");
  
  
          List&lt;ProductOption&gt; productoptions = new ArrayList&lt;ProductOption&gt;();
  
          productoptions.add(po1);
          productoptions.add(po2);
          productoptions.add(po);
  
  
  
          System.out.println("schema!");
          Configuration configuration = new Configuration().configure();
  
          StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
  
          SessionFactory factory = configuration.buildSessionFactory(builder.build());
  
          Session session = factory.openSession();
          session.beginTransaction();
          product.setProductoption(productoptions);
          session.save(product);
          session.getTransaction().commit();
          session.close();
          System.out.println(product.getName());
  
          for(int i=0;i&lt;product.getProductoption().size();i++){
          System.out.println(product.getProductOptionsAsListOfStrings().get(i));  
          System.out.println(product.getProductoption().get(i).getTopping());
          }
  
      }
  
  }
  </code></pre>
  
  <p>For some reason hibernate is inserting null values in foreign key field of productoptions.
  I tried changing cascading styles, generation strategies, but nothing worked. Making nullable=false throws error . Data gets inserted but in the productoptions table foriegn key field is null.
  Please help</p>