From the course: Java EE 8 Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Entity associations

Entity associations - Java EE Tutorial

From the course: Java EE 8 Essential Training

Start my 1-month free trial

Entity associations

- [Instructor] Let's talk in depth about the concept of entity associations in JPA. When we build an object model, it's common for the fields of an object to reference other objects. For example, an order may contain a list of objects of type item. When these objects or entities we need to map these associations or relationships, which are not extremely complex but it's more difficult than simply mapping a table column. In a relational database, tables are referenced using a foreign key relationship. So when we map an association in JPA, we are instructing the entity manager on how to persist two objects that have an underlying foreign key relationship in the database between their tables. There are several considerations when mapping an entity association. First, the cardinality of the relationship must be determined. It is critical to identify if the entities are related through a one-to-one, one-to-many or…

Contents