Is there a way to get a collection mapped in hibernate to load a null value instead of an empty collection if there is no data for the collection in the database?
From the example below there is no data for the keywords list. I would like the PortletInfoImpl created by hibernate to set null for the keywords property instead of an empty list as they have two different meanings for this application.
Hibernate version: 3.2.0-ga
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="org.jasig.portal.portlet.transfer.impl.PortletDefinitionTransferImpl"
table="UP_PORT_DEF">
<id name="portletDefinitionId" type="org.jasig.portal.portlet.dao.hibernate.types.PortletDefinitionIdUserType">
<column name="PORT_DEF_ID"/>
<generator class="assigned"/>
</id>
<component name="portletInfo" class="org.jasig.portal.portlet.common.PortletInfoImpl">
<property name="title" type="string">
<column name="INFO_TITLE"/>
</property>
<property name="shortTitle" type="string">
<column name="INFO_SHORT_TITLE"/>
</property>
<list name="keywords" table="UP_PORT_DEF_INFO_KEYWORDS" cascade="all">
<key>
<column name="PORT_DEF_ID"/>
</key>
<index column="SORT_ORDER"/>
<element type="string">
<column name="KEYWORD" not-null="true"/>
</element>
</list>
</component>
</class>
</hibernate-mapping>
Name and version of the database you are using: HSQL 1.8.0.2