I appreciate the knowledge of dynamic-insert, but it doesn't seem to work in this case. Hibernate is still generating explicit nulls. I guess dynamic-insert does not apply to components, or list of components?
Here is the mapping file.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.mattvanhorn.simetra.model.PersonName" table="PersonName"
dynamic-update="true"
dynamic-insert="true" >
<id name="id" column="id" type="java.lang.Integer" >
<generator class="native"></generator>
</id>
<property
name="formattedName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="formattedName" />
<property
name="legalName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="legalName" />
<property
name="middleName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="middleName" />
<property name="
preferredGivenName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="preferredGivenName" />
<list
name="givenNames"
table="PersonNameGivenName"
lazy="true"
inverse="false"
cascade="all" >
<key column="personName"/>
<index column="list_index"/>
<element
column="givenName"
type="string"
not-null="false"
unique="false" />
</list>
<list
name="familyNames"
table="PersonNameFamilyName"
lazy="true"
inverse="false"
cascade="all" >
<key column="personName"/>
<index column="list_index" />
<composite-element
class="com.mattvanhorn.simetra.model.FamilyName">
<property
name="familyName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="familyName" />
<property
name="primary"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="isPrimary" />
</composite-element>
</list>
<list name="affixes"
table="PersonNameAffix"
lazy="true"
inverse="false"
cascade="all" >
<key column="personName" >
</key>
<index column="list_index" />
<composite-element
class="com.mattvanhorn.simetra.model.Affix" >
<property
name="affix"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="affix" />
<property name="type"
type="com.mattvanhorn.simetra.model.AffixType"
update="true"
insert="true"
access="property"
column="type"
/>
</composite-element>
</list>
</class>
</hibernate-mapping>
In my logs I see:
insert into PersonNameFamilyName (personName, list_index, familyName, isPrimary) values (32, 0, 'bar', null)
isPrimary is an enum with values of 'true', 'false' and 'unknown', and the default is unknown.
_________________ --
Matthew Van Horn
|