I have this mapping:
<?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>
<class name="core.Person" table="person">
<id name="id" type="string" length="32">
<column name="id" length="32" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="firstName" column="firstname" type="string" />
<property name="lastName" column="lastname" type="string"/>
<property name="middleName" column="middlename" type="string"/>
<property name="debug" column="debug" type="string" access="data.DynaObject"/>
<component name="address" class="core.Address">
<property name="street" column="street" type="string"/>
<property name="city" column="city" type="string"/>
<property name="state" column="state" type="string"/>
<property name="zip" column="zip" type="string"/>
<property name="country" column="country" type="string"/>
</component>
<!-- Employee -->
<joined-subclass name="core.Employee" table="employee">
<key>
<column name="person_id" length="32"></column>
</key>
<property name="jobTitle" column = "jobtitle" type="string"/>
<many-to-one name="manager" class="core.Employee">
<column name="manager_id" length="32"></column>
</many-to-one>
<set name="subordinates">
<key>
<column name="manager_id" length="32"></column>
</key>
<one-to-many class="core.Employee"/>
</set>
<!-- Employee -->
<joined-subclass name="core.User" table="user">
<key>
<column name="user_id" length="32"></column>
</key>
<property name="login" column="login" type="string"/>
<property name="password" column="password" type="string"/>
<set name="roles" table="user_role">
<key>
<column name="user_id" length="32"></column>
</key>
<many-to-many class="security.Role">
<column name="role_id" length="32"/>
</many-to-many>
</set>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>
You'll note that the "debug" field in the "Person" object is mapped to a customer setter/getter pair.
If I instantiate a person, set the debug field, and save the person, all is well and the debug field goes into the database (along with much rejoicing).
If, however, I instantiate a User (a joined subclass of Person), and set the debug value, it is reset to null during the save cascade . I can put a breakpoint in my setter and watch it push a null into the field (stack trace here):
Code:
BagSetter.set(Object, Object, SessionFactoryImplementor) line: 23
PojoTuplizer(AbstractTuplizer).setPropertyValues(Object, Object[]) line: 207
PojoTuplizer.setPropertyValues(Object, Object[]) line: 171
JoinedSubclassEntityPersister(BasicEntityPersister).setPropertyValues(Object, Object[], EntityMode) line: 2922
DefaultSaveEventListener(AbstractSaveEventListener).performSaveOrReplicate(Object, Serializable, EntityPersister, boolean, Object, SessionImplementor) line: 223
DefaultSaveEventListener(AbstractSaveEventListener).performSave(Object, Serializable, EntityPersister, boolean, Object, SessionImplementor) line: 158
DefaultSaveEventListener(AbstractSaveEventListener).saveWithGeneratedId(Object, String, Object, SessionImplementor) line: 107
DefaultSaveEventListener(DefaultSaveOrUpdateEventListener).saveWithGeneratedOrRequestedId(SaveOrUpdateEvent) line: 184
DefaultSaveEventListener.saveWithGeneratedOrRequestedId(SaveOrUpdateEvent) line: 33
DefaultSaveEventListener(DefaultSaveOrUpdateEventListener).entityIsTransient(SaveOrUpdateEvent) line: 173
DefaultSaveEventListener.performSaveOrUpdate(SaveOrUpdateEvent) line: 27
DefaultSaveEventListener(DefaultSaveOrUpdateEventListener).onSaveOrUpdate(SaveOrUpdateEvent) line: 69
SessionImpl.save(String, Object) line: 429
SessionImpl.save(Object) line: 424
Tester.main(String[]) line: 60
Can anyone offer me a hint as to why I'm getting a null pushed in during the save cascade? Is there something I have to do to force hibernate to recognize that there's a value in the field so it doesn't try to mash it?