david wrote:
You should be using atleast 1.2.3 which was a start of many enhancements and fixed for hibernate mapping. The CVS version is even better (to be 1.3.x series).
one-to-one should only be used when the primary keys or the two tables in the relationship are used also as the fk- constraint (atleast as you have shown it). Otherwise use many-to-one. See the one-to-one discussion in the manual.
I looked into Hibernate reference:
Alternatively, a foreign key with a unique constraint may be express as many-to-one with unique="true".
In our case, i can't put unique="true" per column since that's composite-id
So i added unique="true" in many-to-one. The same mapping file is generated , didn't see unique="true" there. It works the same as before.
Actually it doesn't matter the mapping is many-to-one or one-to-one for us now, the java class defination is alway the same, the traverse is alway from child to parent ,eg. group.person , not the other way. And the query result is the same. I'll leave it as many-to-one and add unique="true" on it to indicate it's one-to-one for the time being.
I'll give a try to upgrade xdoclet definitely. Thanks.