Design Guidelines for Entity Beans

Discussions

EJB design: Design Guidelines for Entity Beans

  1. Design Guidelines for Entity Beans (6 messages)

    Is there any guidelines that help decide which tables need to be entity beans?

    Threaded Messages (6)

  2. Design Guidelines for Entity Beans[ Go to top ]

    The usual mapping is one table = one entity bean.

    Floyd
  3. Design Guidelines for Entity Beans[ Go to top ]

    Thanks. I would like to know if this mapping is a must? Or, are there guidelines to determine if a table qualifies to be an entity bean.
  4. Design Guidelines for Entity Beans[ Go to top ]

    An entity must have a unique identification (the PK) and should (almost always) have a lifetime which is independent of other entities. I consider an Invoice and a Product an entity and an InvoiceLine to be a dependent object of the Invoice entity that references a Product entity.

    Many of the standard CMP facilities in EJB servers only allow a single row, table-per-entity mapping. I tend to ignore this restriction and either use more powerful containers (WLS with TOPLink, Gemstone/J, etc.) and design my entities accordingly. If you needed to deploy one of my beans on a more limited environment you'd have to create a subclass that was a BMP entity.
  5. Design Guidelines for Entity Beans[ Go to top ]

    We have actually had some success mapping one Entity bean to a view in Oracle; this view combines many tables, and has a PK. It is for read only queries, but is a great way to get aggregated data with one bean. For writing back to the DB, we simply write to each table independently, through individual entity beans.
  6. Design Guidelines for Entity Beans[ Go to top ]

    Refer to The Java 2 Enterprise Edition Developer's Guide, Chapter 9 Advanced Topics (page 135). It helped me clear out most of the doubts I had about mapping entity beans to the relational model, from One-to-One relationships to Many-to-Many relationships. You can download the document freely from the java.sun.com site.
  7. Design Guidelines for Entity Beans[ Go to top ]

    An article by Craig Larman, "Enterprise JavaBeans 201: The Aggregate Entity Pattern", from Software Development Magazine, April 2000, may be of interest.
    http://www.sdmagazine.com/features/2000/04/f3.shtml

    There are some useful thoughts on deciding what to make an entity bean.

    Regards,
    Roger ---|-
    all views are mine ...