Multiplicity affects return type!
A Movie has one Director. When you call getDirector(), you get back one Director. So the return type of getDirector() is a Director().
But a Director has many movies, so when you call getMovies(), you get back a Collection of Movies.
In the Movie-to-Director relationship, the multiplicity of Movie is many and the multiplicity of Director is one.
A multiplicity of one means the object you’re related to holds just one of you.
Director has a multiplicity of one, so the Movie object related to Director returns just a single Director bean (OK, technically the component interface of Director, but you know what we mean by now).
A multiplicity of many means the object you’re related to holds a Collection of you.
Movie has a multiplicity of many, so the Director object related to Movie returns a Collection of Movie beans.
Get Head First EJB now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.