Hello
I'm using hibernate 3.0 and xdoclets and trying to get a XML mapping that looks like:
Code:
<hibernate-mapping >
<class name="hibernate.test.Person" table="PERSONS" lazy="false" >
....
<bag name="addresses" lazy="false" cascade="all-delete-orphan">
<key column="personId" not-null="true" />
<one-to-many class="hibernate.test.Address" />
</bag>
</class>
</hibernate-mapping>
My problem is getting the
key element right!.
My getAddress() method of my Person class looks like:
...
Code:
/**
* @return
*
* @hibernate.bag
* lazy="false"
* cascade="all-delete-orphan"
*
* @hibernate.collection-key
* column="personId"
* not-null="true"
*
* @hibernate.collection-key-column
* name="personId"
* not-null="true"
*
* @hibernate.collection-one-to-many
* class="hibernate.test.Address"
*/
public List getAddresses() {
return addresses;
}
However when I run generate my XML files I get something like
Code:
<bag name="addresses" lazy="false" cascade="all-delete-orphan">
<key>
<column name="personId" not-null="true" />
</key>
<one-to-many class="hibernate.test.Address" />
</bag>
And my little test program fails to save my data (It works fine if I use the fist mapping. My problem is thus adding a not-null attribute to the key element.
Anybody have an idea how to do that?
I've managed to by-pass the problem by removing all xdoclets tag from the getAddress method and using and extension file but that is tedious and removes all the benefit of using xdoclets (ie having to manage two files for one class).
William