java - @OneToMany List<> vs Set<> difference -
is there difference if use
@onetomany public set<rating> ratings; or if use
@onetomany public list<rating> ratings; both work ok, know difference between list , set, don't know if makes difference how hibernate (or rather jpa 2.0) handles it.
a list, if there no index column specified, handled bag hibernate (no specific ordering).
one notable difference in handling of hibernate can't fetch 2 different lists in single query. example, if have person entity having list of contacts , list of addresses, won't able use single query load persons contacts , addresses. solution in case make 2 queries (which avoids cartesian product), or use set instead of list @ least 1 of collections.
it's hard use sets hibernate when have define equals , hashcode on entities , don't have immutable functional key in entity.
Comments
Post a Comment