I am looking for what most people use as their collection type when making one-to-many associations in Hibernate. The legacy application I am maintaining uses bags exclusively, but keeps them as lists in code. The tables associated have an id field, so an idbag seems more appropriate, but documentation recommends a Set.
EDIT: I mistakenly referenced that the documentation recommends a set. In reality, the official documentation is equally vague on all collection types. What I find is that some websites seem to infer that Set is the most common, and the Hibernate book I am reading explicitly says this about sets:
This is the most common persistent collection in a typical Hibernate application. (see: page 242 of ‘Java Persistence with Hibernate’ by Christian Bauer and Gavin King)
I guess that is what threw me and made me seek out what others are using.
EDIT2: note that Gavin King is the creator of Hibernate
Ok, after quite some time I have found a reason NOT to use a Set as a collection type. Due to problems with the hashcode/equals overrides and the way hibernate persists, using any java API functionality that calls hashcode/equals is a bad idea. There is no good way to consistently compare objects pre- and post-persistence. Stick with collections that do not rely on equals/hashcode like
bag.More info here:
http://community.jboss.org/wiki/EqualsandHashCode (this link makes it sound like a business key is the way to go, but read the next link fully to see why that is not always a good idea)
https://forum.hibernate.org/viewtopic.php?f=1&t=928172 (read the whole discussion to make your head spin)