Hello all,
I have a very subtle problem with one-to-many bidirectional associations based on indexed lists, using Hibernate 3.0.5
I've mapped my association following the instructions given in this document:
http://www.hibernate.org/193.html
So, this is my parent mapping:
Code:
<list cascade="all-delete-orphan" inverse="false" lazy="true"
name="requiredDocuments">
<cache usage="read-write"/>
<key column="enrollmentRequest"/>
<index column="displayOrder"/>
<one-to-many class="com.foo.EnrollmentRequestDocument"/>
</list>
And this is my child mapping:
Code:
<many-to-one cascade="none" insert="false" lazy="proxy"
name="enrollmentRequest" not-null="false" update="false"/>
Finally, this is my "add" method in the parent class:
Code:
public void addDocument(EnrollmentRequestDocument document) {
document.setEnrollmentRequest(this);
this.requiredDocuments.add(document);
}
Notice that in the child mapping I had to write not-null="FALSE" because if I set it to TRUE I get a not-null constraint violation when inserting.
However, this doesn't work. The foreign key in the child is not set, nor is set the index column during saving.
Am I missing something relevant?
Thanks in advance,
Sergio B.