File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes how to decide how many entity beans to have Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "how to decide how many entity beans to have" Watch "how to decide how many entity beans to have" New topic

how to decide how many entity beans to have

manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
Hi All
Say i have a database with 40 tables where in each of them i would be having some manipulation(insert/update/delete) as well querying from the same.
In such a scenario how to decide for how many tables do we need to create entity beans
Keith Rosenfield
Ranch Hand

Joined: Nov 25, 2003
Posts: 277
My guess would be 40 entity beans, one for each table.

Keith Rosenfield<br />SCJP<br />SCWCD<br />SCBCD
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
Yup, for CMP the correspondence is going to be close. Ignoring other ways of getting data (views, stored procedures), what you'll have is:
T = number of tables we want to provide data to/from the application
R = number of relationship tables
O = number of other tables maintained outside the application
(e.g. via triggers)
T + R + O = the total number of tables
So "T" would be the number of CMP-based entity beans you'll have. The "R" tables are used for maintaining the constraints, and they'll be mentioned in whatever container-specific deployment descriptor or tool you use for specifying your CMR implementation. The "O" tables are just stuff you are required to have but the application may not care about, like automatically maintained audit trails.

Reid - SCJP2 (April 2002)
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
Though the specs do not require this, some application servers allow entity beans to span across multiple tables. Based on your business functionality, you could have less number of entity beans. But the drawback of this approach, is that it could make your code non-portable across other app servers that do not support this feature...
I agree. Here's the link:
subject: how to decide how many entity beans to have
It's not a secret anymore!