Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'd suggest you first get the Java-only OO model right and then worry about which Hibernate annotations you use. If you find you need to <em>legitimately</em> alter your model for Hibernate to fit in, you can always do so. </p> <p>In the end, this type of problem is typically solved with some variation of the <a href="http://en.wikipedia.org/wiki/Composite_pattern" rel="nofollow">Composite pattern</a> (don't focus too much on the pattern thing, just on the structure and idea behind it.)</p> <p>Using relational database lingo (in a rather relaxed manner): </p> <p>A. If your domains (root domains and sub-domains) are <em>relations</em> (collections of n-tuples in a table with no duplicates and with a discernible primary key) <strong>and</strong></p> <p>B. your domains and sub-domains <em>have similar structure</em>, <strong>then</strong></p> <p>C. You might be able to store all of them in the same physical table by defining a <strong>"parent"</strong> foreign key such that the parent FK of one tuple maps to the primary key of another one.</p> <p>Most importantly, this recursive relationship must be acyclic. How you go about it structurally is up to your problem domain (do you have one root domain, or you can have multiple, unrelated root domains?) A root domain can be denotated by having either a NULL parent foreign key, or with a condition where a root domain tuple's parent foreign key equals its own primary key. Either one has pros and cons (which are the subject of typically stupid flame wars.)</p>
    singulars
    1. This table or related slice is empty.
    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. 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.
 

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