whoops, typo in my question, "completionRewards" and "variables" are one-to-many associations, the mapping xml is correct.
Btw: having unsaved-value="any" in the parent (Survey) and calling session.save(survey) should always save the parent first, no?
Using hibernate 2.1beta6
here is the SurveyVariable mapping, having not-null="true" in the many-to-one causes the following exception...
Code:
java.lang.NullPointerException: not-null property references a null or transient value: com.lsr.eclipse.framework.core.model.SurveyVariable.survey
at net.sf.hibernate.impl.SessionImpl.checkNullability(SessionImpl.java:1144)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:800)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:678)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1324)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:113)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:339)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:429)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:355)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:406)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:385)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:824)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:678)
at com.lsr.eclipse.framework.core.transaction.impl.TransactionPersistSurvey.execute(TransactionPersistSurvey.java:70)
Code:
<class name="com.lsr.eclipse.framework.core.model.SurveyVariable" table="survey_variable">
<id column="survey_variable_id" name="surveyVariableId" length="10" type="java.lang.Long">
<generator class="native"/>
</id>
<property column="table_name" length="64" name="tableName" not-null="true" type="java.lang.String"/>
<property column="column_name" length="64" name="columnName" not-null="true" type="java.lang.String"/>
<many-to-one column="survey_id" name="survey" class="com.lsr.eclipse.framework.core.model.Survey" not-null="true" outer-join="false"/>
</class>