1 Reply Latest reply on Aug 24, 2004 6:22 PM by mindschreck

    CMP and Multiple Table Mappings

    mindschreck

      Greetings,

      I was wondering if there was a way in JBoss to have a single entity bean, but map it's CMP fields to multiple tables that share a one-to-one relationship?

      For example, assume I have an entity bean called PersonBean. In PersonBean, I have CMP fields such as name, address, etc. However, the tables that contain the data are separate; tbl_person and tbl_person_address share a one-to-one relationship.

      Rather than creating an entity bean for PersonAddress and using CMR (which I think may be an anti-pattern, but I'm not sure about this), I would instead like to use some sort of deployment mapping to have the fields from both tables exist in the single bean.

      This is possible. It is mentioned in the J2EE Tutorial (Second Ed.) for Sun Application Server and in WebLogic documentation. However, I have found no mention of it in JBoss documentation (including the JBoss CMP docs).

      If there is a JBoss solution, is there any way to map the fields to the beans using XDoclet? Geez, I'm asking for a lot, aren't I? :-)

      TIA for any assistance!

      Cheers,
      Jason