@Entity public class Media extends Object
It is an example of a ManyToOne uni-directional relationship. There are zero to many MediaCopy(s) for each Media. However, there is no reference to the copies from Media. All access to the copies must come through querying the MediaCopies. MediaCopy happens to both "own" the relationship and be the only that it can be navigated by (uni-directional).
It is also an example of a OneToMany uni-directional relationship using a Join (or Link) table. There are zero to many Media in Inventory. However, there is no reference to the Inventory from this class or MEDIA table. The linkage is done through a separate table defined in the Inventory class. Inventory both "owns" the relationship and is the only side that it can be navigated by. It is also an example of ManyToMany bi-directional relationship. Each Media can have zero to many Authors. Each Author can have zero to many Media. Author "owns" the relationship (thus defines the join/link table). Media only defines the mapping back to Author. The relationship can be navigated by either side.
Modifier and Type | Field and Description |
---|---|
private Collection<Author> |
authors |
private long |
id |
private String |
title |
Constructor and Description |
---|
Media() |
Modifier and Type | Method and Description |
---|---|
Collection<Author> |
getAuthors() |
long |
getId() |
String |
getTitle() |
void |
setAuthors(Collection<Author> authors) |
void |
setTitle(String title) |
String |
toString() |
private long id
private String title
private Collection<Author> authors
public long getId()
public String getTitle()
public void setTitle(String title)
public Collection<Author> getAuthors()
public void setAuthors(Collection<Author> authors)
Copyright © 2015 John's Hopkins University, Engineering Programs for Professionals. All rights reserved.