I have a component mapped using Hibernate. If all fields in the component in the database are null, the component itself is set to null by hibernate. This is the expected behavior and also what I need.
The problem I have, is that when I add a bag to that component, the bag is initialized to an empty list. This means the component has a non null value... resulting in the component being created.
Any idea how to fix this?
<class name="foo.bar.Entity" table="Entity">
<id name="id" column="id">
<generator class="native" />
</id>
<property name="departure" column="departure_time" />
<property name="arrival" column="arrival_time" />
<component name="statistics">
<bag name="linkStatistics" lazy="false" cascade="all" >
<key column="entity_id" not-null="true" />
<one-to-many class="foo.bar.LinkStatistics" />
</bag>
<property name="loggedTime" column="logged_time" />
...
</component>
A criteria with Restirctions.isNull("statistics") does return the expected values.