http://forum.hibernate.org/viewtopic.php?t=968296
http://forum.hibernate.org/viewtopic.php?t=966178
http://forum.hibernate.org/viewtopic.php?t=943384
These posts outlined problems with lists on bi-directional associations.
To sum them, you can't have an inverse="true" one-to-many list. Because your list-index will not automatically update. It will be dropped as an inverse property. That will hurt you in a way you wouldn't soon forget.
The working solution is to make many-to-one end of this association insert="false" update="false", drop inverse="true" and have your list-indexes automatically managed.
But! What if I want to make my many-to-one end of association a natural-id? Like,
<natural-id>
<many-to-one name="parent"
not-null="true"
class="Parent"
column="PARENT_ID" />
<property name="outerId" not-null="true" />
</natural-id>
Adding insert="false" update="false" to natural id component seems dumb to me. Any ideas how to combine list-index and natural-id on the other side?
If it isn't possible, what's your considerations on what's better - natural-id or list-index? I can drop (and hopefully emulate it clumsily) least important of them.
P.S. Of course, the current list-index model is broken. You can't really define your list-index at many-to-one side, so it
should update even when collection is mapped as inverse. Ideally, list-index should have its own insert and update properties, which one could then turn on to make index update even belonging to inverse end of that mapping.
Otherwise it makes NO sense and causes a lot of confusion.
It's not a program bug, it's semantic fault.