title: Which Java Type do you use for JPA collections and why?
body: <p>Which of the following collection types do you use in your JPA domain model and why:</p>
  
  <ul>
  <li><code>java.util.Collection</code></li>
  <li><code>java.util.List</code></li>
  <li><code>java.util.Set</code></li>
  </ul>
  
  <p>I was wondering whether there are some ground rules for this.</p>
  
  <p><strong>UPDATE</strong> I know the difference between a <code>Set</code> and a <code>List</code>. A <code>List</code> allows duplicates and has an order and a <code>Set</code> cannot contain duplicate elements and does not define order. I'm asking this question in the context of JPA. If you strictly follow the definition, then you should always end up using the <code>Set</code> type, since your collection is stored in relational database, where you can't have duplicates and where you have define an order by yourself, i.e. the order in you Java <code>List</code> is not necessarily preserved in the DB.</p>
  
  <p>For example, most of the time I'm using the <code>List</code> type, not because it has an order or allows duplicates (which I can't have anyway), because some of the components in my component library require a list.</p>