How do you model for a JOIN operation in a relational database using entity bean(s)? Do you have to have separate entity beans for each table in the database?

Robert Castaneda

This depends on the granularity and the design of your Entity beans.

A way to do it is to model an Entity for each table and for the join specify a reference to Entity Bean 2 (from table2 ) from Entity Bean 1 (from table 1). If this is a one-to-one relationship then you could easily place these into the same Entity bean - this is a design issue and has other factors involved.

For a one-to-many relationship you could specify a collection of EJB references to Entity Bean 1 inside Entity Bean 2.

If you're using CMP, the above information will be very much reliant on the EJB CMP tool that you are using. Each tool has its strengths. I am basing this response on the Inprise Application Server 4.0.
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact