We need relationships between the Movie bean and the Director bean

We want the Movie bean to have a reference to its matching Director bean and we want to do all sorts of searches against the Movie bean and have the queries use the Director bean’s data as well.

In other words, we want to make it easy on the client (and on the developer) to think in a more natural way, rather than in the database-efficient way that was used to design the schema of the database. Who wants that? Remember, this is the OO world and relational databases, while crucial to your business, are so 1999. We want to use databases, we just don’t want to think like databases. (If you’re one of the lucky ones who gets to use an OO database, and assuming that database still somehow manages to perform well enough for your needs, then you can just smile smugly during this first section.)

image with no caption

We’re not going to use the Trailer table and bean after this (although you’ll see it in code), to keep the example cleaner. Adding the Trailer bean wouldn’t add any new complexity to the application, though. If you can set-up one bean-to-bean relationship, you can set up others.

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.