In these examples on TopLink JPA Annotation Reference:
Example 1-59 @OneToMany - Customer Class With Generics
@Entity
public class Customer implements Serializable {
...
@OneToMany(cascade=ALL, mappedBy="customer")
public Set<Order> getOrders() {
return orders;
}
...
}
Example 1-60 @ManyToOne - Order Class With Generics
@Entity
public class Order implements Serializable {
...
@ManyToOne
@JoinColumn(name="CUST_ID", nullable=false)
public Customer getCustomer() {
return customer;
}
...
}
It seams to me that the Customer entity is the owner of the association. However, in the explanation for the mappedBy attribute in the same document, it is written that:
if the relationship is bidirectional,
then set the mappedBy element on the
inverse (non-owning) side of the
association to the name of the field
or property that owns the relationship
as Example 1-60 shows.
However, if I am not wrong, looks like in the example the mappedBy is actually specified on the owning side of the association, rather than the non-owning side.
So my question is basically:
In a bidirectional (one-to-many/many-to-one) association, which of the entities is the owner? How can we designate the One side as the owner? How can we designate the Many side as the owner?
What is meant by "the inverse side of the association"? How can we designate the One side as the inverse? How can we designate the Many side as the inverse?
Thanks in advance.