Should One Entity Bean map to One Table of Database?

Discussions

EJB design: Should One Entity Bean map to One Table of Database?

  1. Should One Entity Bean map to One Table of Database? (2 messages)

    Hi,

    I know that there is no hard and fast rules that one Entity bean must necessarily map to one Table in the database.

    I like to know what are the general approaches for a design of Entity Bean especially in cases where the data model is such that, you may have to use complex join queries most of the times.

    Thanks,
    Prem.
  2. Hi Prem,

    If you look through the older posts you'll find a lot of discussion on this topic already. Here's my own summary (which naturally is full of holes, since it's a complex issue):

    1. Although the official documentation talks about coarse-grained Entity beans mapped to multiple tables, in reality you're pretty much forced to do a 1-to-1 mapping, especially if you're using CMP beans, double-especially if you're using EJB 1.1.

    2. For more complex stuff, you either have to define entity relationships or bypass the entity beans. I suspect that the latter is what you should look for unless you have a strong need for the caching features provided by entity beans. Stateless session beans only is still EJB.
  3. Hi !

    If you must map a EJB to different tables the simplest way is to make a view with fields from this table ...