| Relationship | Bidirectionality |
|---|---|
Simple Relationship (one-to-one)Java CodeBar Foo.getBar() // returns corresponding Bar instance
Hibernate Mapping
|
Yes. Just add a similar mapping and Foo property to Bar |
Simple Reference (many-to-one)Java CodeBar Foo.getBar() // returns corresponding Bar instance
Hibernate Mapping
|
Yes. Just add a similar mapping and Foo property to Bar. Just add an extra column in Bar's table called foo_id |
Basic Collection (one-to-many)Java CodeSet Foo.getBars() // returns a collection of Bar instances
Hibernate Mapping
|
Relationship can be established both ways. Just refer to the many-to-one relationship |
Collection (many-to-many)Java CodeSet Foo.getBars() // returns a collection of Bar instances
Hibernate Mapping
|
Relationship can be established both ways. Just refer to the many-to-one relationship |
Glossary:
First-rank classes are those with their own mapping definition for Hibernate entities and must always be explicitly persisten.
Second-rank classes are those with enclosed by first-rank classes or persisted throught associations or relationships with a first-rank class.
Source:
Xylax.net




