Simple CMP Entity - relationship question


EJB design: Simple CMP Entity - relationship question

  1. Simple CMP Entity - relationship question (2 messages)


    I have a Order and an OrderLine bean. The OrderLine bean goes like this:

    public class OrderLineBean {
       public int quantity;
       public Order order; // reference to order

    I have EJB 1.1 and would like to use the features there and avoid referencing through PK's etc. I have the Roman book which is very good, but I does not show the details in EJB 1.1

    1) What datatype should I use at the database for the Order-column in the OrderLine-table? String, Binary, Blob...?

    2) Could the orderlines be created by the Order itself in it's create-methode? If yes, how can I send a reference to "my self" and should it be done from ejbCreate() or ejbPostCreate() or somewhere else?
    Or must it be created from another bean?

    3) All this seem to be fairly basic questions, but I can't find any stuff on this in the docs. Can anyone recomend a site or book on this stuff?

    I have:
    WinNT 4
    WLE 5.0.1
    Oracle 8.1.5

  2. Richard Monson Haefel's book has a chapter in the end - "Design Strategies" which talks abt implementing one-many relationships.
  3. Hi,

    The EJB 1.1 spec only define the ref feature BUT not the way the container provider should implement it.
    That's mean your container probably resolve it by using the primary key of your table (but the best thing is to test it!!). So you only need a corresponding foreign key column in your master table with the same datatype defining in your other table (primary key).
    The deployement descriptor simply describe it as a reference corresponding to your Order bean.

    Unfortunatelly, I also didn't find a lot of information in books since this feature has been specified in the EJB 1.1 and a lot of books are based on EJB 1.0...

    Hope this helps,