When you work on designing and defining objects, you have to think past the object itself. One of the most important things to define is the relationship between objects. This makes sense: after all, with a data model, we define both entities and relationships.
Seven different types of relationships can be defined:
One-to-one, unidirectional
One-to-one, bidirectional
One-to-many, unidirectional
One-to-many, bidirectional
Many-to-one, unidirectional
Many-to-many, unidirectional
Many-to-many, bidirectional
Unidirectional refers to one object defining the relationship, or you can get from one of the objects to the other but not vice versa. In a bidirectional relationship, both objects define the relationship, or you can get from one object to the other in either direction. The multiplicity determines the roles of the relationship between the two entities. For example, in our project, a Product can have multiple ProductKeys, but a ProductKey can only belong to a single Product; that defines a one-to-many relationship. Through a Product you can attain all its ProductKeys and from a ProductKey you can find out its Product, so this is a bidirectional relationship.
Relationships are defined between entities at a database level by exchanging of entity primary keys where appropriate. In our project, the ProductKey table contains the primary key of the Product table, so we can add as many ProductKey entries as required without having to make any adjustments to the Product table. Queries for a Product's ProductKeys involve obtaining the requested Product's primary key and then querying for all ProductKeys with the product_id that matches the primary key.
ejb-jar.xml
Fortunately, the EJB 2.0 specification abstracts the technical details of defining object relationships. That lets us focus on the relationship itself. We simply need to understand the multiplicity and directionality of the relationship and then define the relationship in the ejb-jar.xml deployment descriptor.
reply or leave comment
|
|
|
|