EJB design: Enterprise Application Design
- Posted by: Matthias Zint
- Posted on: July 08 2004 10:09 EDT
this is just a general question on design.
I'm working with a very small example implementation at the moment. My data structure consists of 7 tables. Each of them is mapped to a EntityBean with Container Managed Persistence (CMP & CMR).
I use a stateless SessionBean as a Facade for the data access.
Is there another way to map database tables to beans ?? If I have a database structure which consists of maybe 100 tables: Do I have to map every table to an Entity Bean, if I'd need to access data from each and every table.
Any best practices for EnterpriseBean-Design ?? Any restrictions with Container Managed Persistence ??
Do a search for 'CMP' or 'Entity Bean' on this site and you will find that most developers avoid entity beans, especially CMP.
You could use a couple of nice J2EE patterns to help out.
The Composite Entity pattern recommends using a few, coarse grained Entity beans rather than lots of little ones. You might have fun using CMP with this though. I would recommend using the Data Access Objects DAO pattern with this - have a Composite Entity manage mutiple DAO's.
You will find that CMP generally doesn't scale that well.
To remove the drudgery from coding lots of database access code I would recommend using a generation tool - either Middlegen (http://boss.bekk.no/boss/middlegen/) for CMP or Torque (http://db.apache.org/torque/) wrapped by your DAO's.
Hope this helps!