Quote:
I've thought of another example: An Article and a Person object. An Article can have an author and editor, both of which are instances of Person.
If you really want that a determinate person can be the author (and editor) of maximal one article,
then I would map it in following way:
Code:
@Entity
public class Article {
@Id
...
@OneToOne
protected Person author;
@OneToOne
protected Person editor;
}
@Entity
public class Person {
@Id
...
@OneToOne(mappedBy="author")
protected Article authorOf;
@OneToOne(mappedBy="editor")
protected Article edited;
}
In this way there's no join table and the 2 relationships are clearly distinguished.
Also the schema is easy readable and intuitive.
If you indeed you don't want to declare a separate relation for each type (tallest, mostintelligent, leastIntelligent, etc.),
then I think that a join table (cross-table) becomes indispensable. I can't imagine how it should work without.