This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate Collection usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Collection usage" Watch "Hibernate Collection usage" New topic

Hibernate Collection usage

Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 253


I know that hibernate provides a range of collection to be used. These are List,Set,Map,Bag,Array and primitive-array.
Can some one please suggest on what situation, which collection should be used ?
If we use map, what would work as key and what would work as value ?

Salil Verma
Bill Gorder

Joined: Mar 07, 2010
Posts: 1632

Typically a Set is suggested if it will do the trick, when it does not I typically use a List. The important thing is to use the interface. The reason is HIbernate will provide its own implementation. I do not use any of the others.

[How To Ask Questions][Read before you PM me]
I agree. Here's the link:
subject: Hibernate Collection usage
Similar Threads
Question on Association mappings
Garbage collection - arrays
String[] to columns
Single table / Simple Locking - WeakHashMap vs WeakReferences
HashMap/Tree map question