title: Hibernate retrieving an extra, NULL, row
body: <p>I have two tables <strong>Config</strong> and <strong>Setting</strong> where <strong>Setting</strong> are part (children) of a <strong>Configuration</strong>.</p>
  
  <p>I'm using HibernateDaoSupport.find() to retrieve a Configuration and the resulting object contains 3 Settings, one of which is <strong>null</strong>. Not an object with empty values, but just <strong>null</strong>.</p>
  
  <p>According to the logs Hibernate found only two rows:</p>
  
  <pre><code>DEBUG [org.hibernate.jdbc.ConnectionManager] - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
  DEBUG [org.hibernate.engine.TwoPhaseLoad] - resolving associations for [com.xx.Setting#1]
  DEBUG [org.hibernate.engine.TwoPhaseLoad] - done materializing entity [com.xx.Setting#1]
  DEBUG [org.hibernate.engine.TwoPhaseLoad] - resolving associations for [com.xx.Setting#2]
  DEBUG [org.hibernate.engine.TwoPhaseLoad] - done materializing entity [com.xx.Setting#2]
  DEBUG [org.hibernate.engine.loading.CollectionLoadContext] - 1 collections were found in result set for role: com.xx.Configuration.settings
  DEBUG [org.hibernate.engine.loading.CollectionLoadContext] - collection fully initialized: [com.xx.Configuration.settings#1]
  DEBUG [org.hibernate.engine.loading.CollectionLoadContext] - 1 collections initialized for role: com.xx.Configuration.settings
  DEBUG [org.hibernate.loader.Loader] - done loading collection
  </code></pre>
  
  <p>and then</p>
  
  <pre><code>DEBUG [org.hibernate.pretty.Printer] - com.xx.Setting{dataType=TEXT, name=xx, id=1, value=xx}
  DEBUG [org.hibernate.pretty.Printer] - com.xx.Configuration{settings=[null, com.xx.Setting#1, com.xx.Setting#2], id=1, bu=xx}
  DEBUG [org.hibernate.pretty.Printer] - com.xx.Setting{dataType=TEXT, name=xx, id=2, value=xx}
  </code></pre>
  
  <p>As you can see it found only 2 <strong>Setting</strong> but the collection contains 3.</p>
  
  <p>EDIT: Following is the Hibernate mapping</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
    &lt;class name="com.xx.Configuration"
           table="sf_config"
           dynamic-insert="false" dynamic-update="false"
           mutable="true" optimistic-lock="version"
           polymorphism="implicit" select-before-update="false" lazy="false"&gt;
      &lt;id access="field" name="id"&gt;
        &lt;generator class="native"/&gt;
      &lt;/id&gt;
      &lt;natural-id&gt;
        &lt;property name="bu" access="field"/&gt;
      &lt;/natural-id&gt;
  
      &lt;list access="field" name="settings" table="sf_setting" lazy="false" cascade="all-delete-orphan"&gt;
        &lt;key&gt;
          &lt;column name="configId"/&gt;
        &lt;/key&gt;
        &lt;list-index column="id"/&gt;
        &lt;one-to-many class="com.xx.Setting"/&gt;
      &lt;/list&gt;
  
      &lt;property name="recordState" access="field"/&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  
  &lt;hibernate-mapping&gt;
    &lt;class name="com.xx.Setting"
           table="sf_setting"
           dynamic-insert="false" dynamic-update="false"
           mutable="true" optimistic-lock="version"
           polymorphism="implicit" select-before-update="false" lazy="false"&gt;
      &lt;id access="field" name="id"&gt;
        &lt;generator class="native"/&gt;
      &lt;/id&gt;
  
      &lt;property name="name" access="field"/&gt;
      &lt;property name="value" access="field"/&gt;
      &lt;property name="dataType" access="field"/&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>