Hello,
i got a problem with a simple one to many association.
i have a first table 'VarReportSetup' and a second one, 'VarReportAggregationTerm', which links the first one with a foreign key.
All i want to do is to define a new VarReportSetup, associate some VarReportAggregationTerm, and then make a cascading insertion, but it doesn't work. I succeed in loading a VarReportSetup and then update it with new VarReportAggregationTerms.
Here is the mapping of the first table :
Code:
<class name="VarReportSetup" table="VarReportSetup">
<...>
<set name="aggregationTermCollection" table="VarReportAggregationTerm" cascade="all" inverse="true" sort="natural">
<key column="VarReportSetupId" not-null="true" />
<one-to-many class="VarReportAggregationTerm"/>
</set>
</class>
Here is the mapping of the second table
Code:
<class name="VarReportAggregationTerm" table="VarReportAggregationTerm">
<...>
<property
name="VarReportSetupId"
column="VarReportSetupId"
type="binary"
not-null="true"
length="12"
/>
</class>
And then the stack trace :
Code:
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.reuters.hibernate.test.VarReportAggregationTerm.VarReportSetupId
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:284)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:186)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:123)
I tried to put a many to one association in the VarReportAggregationTerm mapping file
Code:
<many-to-one name="VarReportSetupId" class="VarReportSetup" column="VarReportSetupId" not-null="true" />
but i get the same error.
Many thanks for your help :)