carlos.l.sanchez wrote:
For associated collections (that can e.g. be cascaded to) the preferred collection interface seems to be Set (mapped using the <set/> tag). The rationale being that Sets are closest to the relational model.
For collections returned from queries, however, the only choice seems to be a List (or an Iterator). This doesn't seem consistent, but there may be a good reason, which has just escaped me so far. I may also be missing something.
In any event, I appreciate any clarifications ;-) I am suggesting changes to our current persistence architecture choices (using Hibernate, of course), and need as many facts as I can get. (This is a big project...)
I am new to Hibernate as well, and here is how I understand it.
when you map a collection, it is based on one-to-many, many-to-one, or many-to-many, in any case there is relations between the database tables
"Referational integrity". Elements in a SET are unique, and hence it insure that every element in the set is unique. It reflects the Referational Integrity of your database.
When you query the database, the result is not neccesserly unique. One might allow same data rows to exist more than once. In addition, you might query for some attributes duplication of data is possible.