title: Hibernate one-to-one .. Do not persist dependent object if its table is empty
body: <p>Am using hibernate with <code>one-to-one</code> mapping.</p>
  
  <p>I have 2 tables <code>Customer</code> and <code>CustomerAddress</code>. </p>
  
  <p><code>CstId</code> is the primary key in Customer table and it is the foreign key in CustomerAddress table. I have a sql which does left outer join on both table to fetch different column values from both tables.  </p>
  
  <p><strong>Problem:</strong> For first time, <code>CustomerAddress</code> table is empty, after doing some updates on the <code>Customer</code> object table am saving the <code>Customer</code> object. This is creating a row of <code>CustomerAddress</code> to be created with same <code>CstId</code>, </p>
  
  <p><strong>Required Solution:</strong> I dont want <code>CustomerAddress</code> row to be persisted unless there exists a row in <code>CustomerAddress</code> for the <code>CstId</code> from <code>Customer</code>. </p>
  
  <p><strong>Mappings:</strong>
  <em>Customer.hbm.xml</em>
      <code>&lt;one-to-one name="customerAddress" class="com.test.CustomerAddress" fetch="join" lazy="false" cascade="save-update, merge"/&gt;</code></p>
  
  <p><em>CustomerAdress.hbm.xml</em>
      <code>&lt;one-to-one name="Customer" class="com.test.Customer" constrained="true" /&gt;</code></p>