steve wrote:
Its more that an array (just like a List) by definition has an order, a sequence. In an array, that sequence is based on the elements position within the array.
Exactly. In a List, you need a heuristic for seeing how two elements are ordered since if you add a new element the list needs to figure out where it goes. For arrays, that is not the case. One point of an array is the program decides the unique ordering from the outside, not by inspecting each object.
I like how Hibernate is pure about everything, but there is a serious disconnect here. In relational databases, the default 1-to-many relationship is not ordered. e.g. a Person has many affiliations, but these are in no particular order. So for legacy data this is needed. On the web side, some frameworks need an order. e.g. the when the textfield in the 3rd row is edited, it needs to save back to the 3rd affiliation. Therefore there is ordering. So for legacy frameworks, arrays should be supported. When these go back in the DB, just take the array, and use the primary key for each object, and update them (or disassociate them if they arent in the array anymore)
steve wrote:
If you don't agree with this, or feel strongly about it, I'm sure we would consider a patch that implemented this for arrays while leaving the default behaviour as-is.
I think it would help out a large array of new developers so they can be all set with Hibernate. If no one is interested in the coding, I could take this on as a long-term project... (busy at the moment, but would like to give it a try eventually), though let me know if it will be accepted once written...
Thanks!
Chris