title: Hibernate throwing exception on insert on one-to-many
body: <p>I have the following DB tables:</p>
  
  <pre><code>CREATE TABLE DS_NVALUES(
    id Number NOT NULL,
    value1 Number(3,0),
    value2 Number(3,0),
    CONSTRAINT ds_nvalues_id PRIMARY KEY (id)
  )
  
  CREATE TABLE DS_AREA(
    id Number NOT NULL,
    id_nvalues Varchar2(15),
    n_c Number(4,0),  
    CONSTRAINT ds_area_id PRIMARY KEY (id)
  )
  </code></pre>
  
  <p>One DSNValue can has a list of DSAreas.
  These are the mapping files:</p>
  
  <pre><code>&lt;hibernate-mapping package="es.entities"&gt;
      &lt;class name="DSValues" table="ds_nvalues" lazy="false"&gt;
          &lt;id name="id" column="id"&gt;
              &lt;generator class="org.hibernate.id.MultipleHiLoPerTableGenerator"&gt;
                  &lt;param name="table"&gt;igea_codigos&lt;/param&gt;
                  &lt;param name="primary_key_column"&gt;nombre&lt;/param&gt;
                  &lt;param name="value_column"&gt;codigo&lt;/param&gt;
                  &lt;param name="primary_key_value"&gt;ds_nvalues&lt;/param&gt;
                  &lt;param name="max_lo"&gt;0&lt;/param&gt;
              &lt;/generator&gt;
          &lt;/id&gt;       
          &lt;property name="value1" column="value1"/&gt;
          &lt;property name="value2" column="value2"/&gt;
  
          &lt;property name="codedId" formula="encode_id('ds_nvalues', id)"/&gt;
  
          &lt;bag name="areas" table="ds_area" cascade="save-update, delete" fetch="select" lazy="false" inverse="true" &gt;
              &lt;key property-ref="codedId"&gt;
                  &lt;column name="id_nvalues"/&gt;
              &lt;/key&gt;
              &lt;one-to-many class="es.entities.DSArea" not-found="exception" /&gt;
          &lt;/bag&gt;
  
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  
  
  
  &lt;hibernate-mapping package="es.entities"&gt;
      &lt;class name="DSArea" table="ds_area" lazy="false"&gt;
          &lt;id name="id" column="id"&gt;
              &lt;generator class="org.hibernate.id.MultipleHiLoPerTableGenerator"&gt;
                  &lt;param name="table"&gt;igea_codigos&lt;/param&gt;
                  &lt;param name="primary_key_column"&gt;nombre&lt;/param&gt;
                  &lt;param name="value_column"&gt;codigo&lt;/param&gt;
                  &lt;param name="primary_key_value"&gt;ds_area&lt;/param&gt;
                  &lt;param name="max_lo"&gt;0&lt;/param&gt;
              &lt;/generator&gt;
          &lt;/id&gt;
          &lt;property name="n_c" column="n_c"/&gt;
  
          &lt;many-to-one name="dsValues" class="es.entities.DSValues"  unique="true" fetch="select"&gt;
              &lt;column name="id_nvalues" write="encode_id('ds_nvalues', ?)"            read="decode_id(id_nvalues)"/&gt;
          &lt;/many-to-one&gt; 
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>And when I create a new DSNValue I hace the following code:</p>
  
  <pre><code>DSArea area1 = new DSArea();
  area1.setN_c(300);
  List&lt;DSArea&gt; areas = new ArrayList&lt;DSArea&gt;();
  areas.add(area1);
  
  DSValues dsValues = new DSValues();
  dsValues.setValue1(3);
  dsValues.setValue2(4);
  dsValues.setAreas(areas);
  area1.setDsValues(dsValues);
  
  Session session = getCurrentSession();
  Transaction t = session.beginTransaction();     
  try{
      session.save(dsValues);
      t.commit();
  }catch(Exception e){
      t.rollback();           
  }
  </code></pre>
  
  <p>t.commit throws a NullPointerException, but in the hibernate log I can see the INSERT statements an its values and they are ok. For selecting the DB elements this mapping configuration works fine. What can be happening?</p>
  
  <pre><code>java.lang.NullPointerException
              at 
  org.hibernate.type.descriptor.java.AbstractTypeDescriptor.extractHashCode(AbstractTypeDescriptor.java:88)
          at org.hibernate.type.AbstractStandardBasicType.getHashCode(AbstractStandardBasicType.java:210)
          at org.hibernate.type.AbstractStandardBasicType.getHashCode(AbstractStandardBasicType.java:214)
          at org.hibernate.engine.spi.CollectionKey.generateHashCode(CollectionKey.java:86)
          at org.hibernate.engine.spi.CollectionKey.&lt;init&gt;(CollectionKey.java:74)
          at org.hibernate.engine.spi.CollectionKey.&lt;init&gt;(CollectionKey.java:50)
          at org.hibernate.event.internal.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:369)
          at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:53)
          at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1233)
          at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:403)
          at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
          at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
          at es.indra.rbc.da.impl.oracle.dao.OracleElementDAO.insert(OracleElementDAO.java:51)
  </code></pre>