title: not-null property references a null or transient value
body: <p>Facing trouble in saving parent/child object with hibernate. Any idea would be highly appreciated.</p>
  
  <pre><code>org.hibernate.PropertyValueException: not-null property references a null or transient value: example.forms.InvoiceItem.invoice
      at org.hibernate.engine.Nullability.checkNullability(Nullability.java:100)
          .... (truncated)
  </code></pre>
  
  <p>hibernate mapping:</p>
  
  <pre><code>&lt;hibernate-mapping package="example.forms"&gt;
      &lt;class name="Invoice" table="Invoices"&gt;
          &lt;id name="id" type="long"&gt;
              &lt;generator class="native" /&gt;
          &lt;/id&gt;
          &lt;property name="invDate" type="timestamp" /&gt;
          &lt;property name="customerId" type="int" /&gt;
          &lt;set cascade="all" inverse="true" lazy="true" name="items" order-by="id"&gt;
              &lt;key column="invoiceId" /&gt;
              &lt;one-to-many class="InvoiceItem" /&gt;
          &lt;/set&gt;
      &lt;/class&gt;
      &lt;class name="InvoiceItem" table="InvoiceItems"&gt;
          &lt;id column="id" name="itemId" type="long"&gt;
              &lt;generator class="native" /&gt;
          &lt;/id&gt;
          &lt;property name="productId" type="long" /&gt;
          &lt;property name="packname" type="string" /&gt;
          &lt;property name="quantity" type="int" /&gt;
          &lt;property name="price" type="double" /&gt;
          &lt;many-to-one class="example.forms.Invoice" column="invoiceId" name="invoice" not-null="true" /&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>InvoiceManager.java</p>
  
  <pre><code>class InvoiceManager {
  
      public Long save(Invoice theInvoice) throws RemoteException {
          Session session = HbmUtils.getSessionFactory().getCurrentSession();
          Transaction tx = null;
          Long id = null;
          try {
              tx = session.beginTransaction();
              session.persist(theInvoice);
              tx.commit();
              id = theInvoice.getId();
          } catch (RuntimeException e) {
              if (tx != null)
                  tx.rollback();
              e.printStackTrace();
              throw new RemoteException("Invoice could not be saved");
          } finally {
              if (session.isOpen())
                  session.close();
          }
          return id;
      }
  }
  </code></pre>
  
  <p>Invoice.java</p>
  
  <pre><code>public class Invoice implements java.io.Serializable {
      private Long id;
      private Date invDate;
      private int customerId;
      private Set&lt;InvoiceItem&gt; items;
  
      public Long getId() {
          return id;
      }
      public Date getInvDate() {
          return invDate;
      }
      public int getCustomerId() {
          return customerId;
      }
      public Set&lt;InvoiceItem&gt; getItems() {
          return items;
      }
      void setId(Long id) {
          this.id = id;
      }
      void setInvDate(Date invDate) {
          this.invDate = invDate;
      }
      void setCustomerId(int customerId) {
          this.customerId = customerId;
      }
      void setItems(Set&lt;InvoiceItem&gt; items) {
          this.items = items;
      }
  }
  </code></pre>
  
  <p>InvoiceItem.java</p>
  
  <pre><code>public class InvoiceItem implements java.io.Serializable {
      private Long itemId;
      private long productId;
      private String packname;
      private int quantity;
      private double price;
      private Invoice invoice;
  
      public Long getItemId() {
          return itemId;
      }
      public long getProductId() {
          return productId;
      }
      public String getPackname() {
          return packname;
      }
      public int getQuantity() {
          return quantity;
      }
      public double getPrice() {
          return price;
      }
      public Invoice getInvoice() {
          return invoice;
      }
      void setItemId(Long itemId) {
          this.itemId = itemId;
      }
      void setProductId(long productId) {
          this.productId = productId;
      }
      void setPackname(String packname) {
          this.packname = packname;
      }
      void setQuantity(int quantity) {
          this.quantity = quantity;
      }
      void setPrice(double price) {
          this.price = price;
      }
      void setInvoice(Invoice invoice) {
          this.invoice = invoice;
      }
  }
  </code></pre>