60 likes | 152 Vues
Learn about one-to-one, one-to-many, and many-to-many relationships in entity beans using CMP. Explore examples such as Department-Employee, Employee-Department, and Book-Author relationships. Implement relationships with abstract getter/setter methods and deployment descriptors.
E N D
Relationships Celsina Bignoli bignolic@smccd.net
Cardinality • One-to-one(1:1) • One office has one address • One-to-many (1:N) • A group and the people part of it • Many-to-many(M:N) • Student takes many classes, a class has many students
1:1 Relationship - Example Department Employee Foreign key
1:N Relationship Example Employee Foreign key Department
M:N Relationship Example Book Author Book_Author
Implementing Relationships Using CMP • Entity Bean has no fields • Getter/setter methods are declared abstract • ejbCreate(), ejbLoad(), ejbStore() have no code • Relationships are defined in the deployment descriptor