The Java Persistence API is the standard framework for persistence in both Java SE and Java EE platforms. It is the outcome of the collaborative work of the industry’s leading vendors in object-relational mapping, EJB and JDO, including a remarkable contribution from the open source community.
In this post we summarize, one-by-one, the essential relationships between entities. We examine each relationship from the prespectives of “Domain Model” and “Relation Model”, and provide the associated construction in JPA. Finally, for each relationship we present an example from the real world.
The relationships are divided in two categories. “For daily use” presents the correct way to use common relationships in our application development activities. On the other hand, “Containing pitfalls” identify common mistakes.
For daily use:
- One-to-One (one direction)
- One-to-One (both directions)
- Many-to-One (one direction)
- Many-to-One (both directions)
- One-to-Many (one direction)
- One-to-Many (both directions)
- Many-to-Many (both directions)
View original post 1,025 more words