Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Like your own question suggests, <strong>the key is the domain, not JPA</strong>. JPA is just a framework which you can (and should) use in a way which best fits your problem. Choosing a suboptimal solution because of framework (or its limits) is usually a warning bell.</p> <p>When I need a set and never care about order, I use a <code>Set</code>. When for some reason order is important (ordered list, ordering by date, etc.), then a <code>List</code>.</p> <p>You seem to be well aware of the difference between <code>Collection</code>, <code>Set</code>, and <code>List</code>. The only reason to use one vs. the other depends only on your needs. You can <strong>use them to communicate to users of your API (or your future self) the properties of your collection</strong> (which may be subtle or implicit). </p> <p>This is follows the exact same rules as using different collection types anywhere else throughout your code. You could use <code>Object</code> or <code>Collections</code> for all your references, yet in most cases you use more concrete types.</p> <p>For example, when I see a <code>List</code>, I know it comes sorted in some way, and that duplicates are either acceptable or irrelevant for this case. When I see a <code>Set</code>, I usually expect it to have no duplicates and no specific order (unless it's a <code>SortedSet</code>). When I see a <code>Collection</code>, I don't expect anything more from it than to contain some entities.</p> <p>Regarding list ordering... Yes, it can be preserved. And even if it's not and you just use <code>@OrderBy</code>, it still can be useful. Think about the example of event log sorted by timestamp by default. Artificially reordering the list makes little sense, but still it can be useful that it comes sorted by default.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload