I'm having a problem where a list mapping produces a null object at the beginning of the list. Here is the mapping:
Code:
<class name="com.upfactor.rns.domain.security.Page" table="page">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">page_id_seq</param>
</generator>
</id>
<many-to-one name="parent" column="parent_id" class="com.upfactor.rns.domain.security.Page"/>
<property name="name" column="name"/>
<property name="url" column="url"/>
<property name="isSecure" column="is_secure"/>
<property name="orderIndex" column="order_index"/>
<list name="children" table="page" inverse="true" lazy="true">
<key column="parent_id"/>
<index column="order_index" />
<one-to-many class="com.upfactor.rns.domain.security.Page"/>
</list>
</class>
Does anyone know why Hibernate would do this? I've tried to narrow the search down with the where attribute (like making sure parent_id is not null), but to no effect. order_index follows an application constraint where a page's children cannot share the same index (this is tested and it works). So, if the page had 3 children, they would have unique order_indexs (1,2 and 3). However, when I get the children, I get a list of 4 objects with the first being null. very strang.