Do join tables have to be represented as a CMP Entity?

Discussions

EJB programming & troubleshooting: Do join tables have to be represented as a CMP Entity?

  1. Hello all,
     
    I'm coming across a little problem. In my database design I have the following tables:
     
    PROPOSAL is linked to PROPOSAL_ROLE by 1-M
    PROPOSAL_ROLE is linked to USER by M-1.
     
    Therefore PROPOSAL_ROLE is used as a join table that will link the two other tables. This is used because a user can play a certain role on many different proposals, and a proposal can have many users that it's involved with.
     
    I've currently implemented the PROPOSAL_ROLE table as ProposalRole CMP Entity bean and specified the above relationships in ejb-jar.xml, but I'm looking at another example using WebLogic 6.1, and in the file weblogic-cmp-rdbms-jar.xml, they are specifiying the join table relationships and NOT creating a CMP entity bean for the join table, but instead just specifying the MANY-TO-MANY relationships between the two beans in ejb-jar.xml. Therefore in my example the proposal bean would proposal.getUsers(), and the user bean would have user.getProposals(). This way I would not have to model the ProposalRole as an entity bean with getProposal() and getUser() methods, rather this would happen "behind the scenes." However, in my join table PROPOSAL_ROLE, I am storing two other fields that are important in recognizing the particular relationship. I've included a "role" and "effort percent" column that give particular data about the relationship that a user has with a particular proposal in the system. So I can see why I would want to have a ProposalRoleBean in this case to be able to access that data.
     
    I guess what I'm really asking is this: Do all JOIN tables have to modeled as CMP Entity beans if the table in itself contains columns of data on top of just storing the two foreign keys of the other two linked tables? Also, how does one specify the links between the join table and the two other tables in Resin (similar to how weblogic-cmp-rdbms-jar.xml does it)?
     
    Thanks for any suggestions!
    Ryan LeCompte
    rml7669 at louisiana dot edu
    http://www.louisiana.edu/~rml7669
     

  2. It's no longer a join table when you have other columns in it... then it's just a table table.

    So your assumption is correct, if you have a join table with nothing but foreign keys in it, you can use it in CMR to model a N-M relationship. If the join table has other data in it, you need to define the join table as a bean and have two 1-N relationships instead.

    No idea about resin.

    Cheers,

    Daniel.