Discussions

EJB design: CMR Relationship Problem

  1. CMR Relationship Problem (1 messages)

    Dear All,

    I am new to EJB and trying to learn CMR relationships


    Suppose I have one master table
    TABLE NAME : ORDER_HEADER
    OrderNo number(5,0) not null,
    CustNo number(5,0) not null,
    OrderDate Date not null,

    constraint pk_order_header primary key ( OrderNo,CustNo,OrderDate)



    And Detail Table

    TABLE NAME: ORDER_LINE

    OrderNo number(5,0) not null,
    CustNo number(5,0) not null,
    OrderDate Date not null,
    LineNo number(5,0) not null,
    ItemNo number(5,0)
    Qty number(5,0)
    Rate number(7,2),
    constraint pk_order_detail primary key (OrderNo,CustNo,OrderDate,LineNo),
    constraint fk_order_detail_order_header FOREIGN KEY (OrderNo,CustNo,OrderDate) REFERENCES OrderHeader (OrderNo,CustNo,OrderDate)


    Now I want write cmr relationship for these two tables using entity beans

    which one of following is correct

    1)
    public abstract class OrderHeaderBean implements EntityBean {
    private EntityContext ctx;

    /********* CMP ***********/
    public abstract Integer getOrderNo();
    public abstract void setOrderNo(Integer orderNo);
    public abstract Integer getCustNo();
    public abstract void setCustNo(Integer custNo);
    public abstract long getInvDate();
    public abstract void setInvDate(long invDate)


    /********* CMR ***********/

    public abstract java.util.Collection orderLines getOrderLines();
    public abstract void setOrderLines(java.util.Collection orderLines);

    ............................

    ...........................


    public abstract class OrderLineBean implements EntityBean {
    private EntityContext ctx;

    /********* CMP ***********/
    public abstract Integer getOrderNo();
    public abstract void setOrderNo(Integer orderNo);
    public abstract Integer getCustNo();
    public abstract void setCustNo(Integer custNo);
    public abstract long getInvDate();
    public abstract void setInvDate(long invDate);
    public abstract Integer getLineNo();
    public abstract void setLineNo(Integer lineNo);
    public abstract Integer getItemNo();
    public abstract void setItemNo(Integer itemNo);
    public abstract Integer getQty();
    public abstract void setQty(Integer qty);
    public abstract float getRate();
    public abstract void setRate(float rate);



    /********* CMR ***********/

    public abstract OrderHeaderLocal orderLines getOrderHeader();
    public abstract void setOrderHeader(OrderHeaderLocal orderHeader);

    .....................
    .....................


    }

    OR


    2)
    public abstract class OrderHeaderBean implements EntityBean {
    private EntityContext ctx;

    /********* CMP ***********/
    public abstract Integer getOrderNo();
    public abstract void setOrderNo(Integer orderNo);
    public abstract Integer getCustNo();
    public abstract void setCustNo(Integer custNo);
    public abstract long getInvDate();
    public abstract void setInvDate(long invDate)


    /********* CMR ***********/

    public abstract java.util.Collection orderLines getOrderLines();
    public abstract void setOrderLines(java.util.Collection orderLines);

    ............................

    ...........................


    public abstract class OrderLineBean implements EntityBean {
    private EntityContext ctx;

    /********* CMP ***********/
    public abstract Integer getLineNo();
    public abstract void setLineNo(Integer lineNo);
    public abstract Integer getItemNo();
    public abstract void setItemNo(Integer itemNo);
    public abstract Integer getQty();
    public abstract void setQty(Integer qty);
    public abstract float getRate();
    public abstract void setRate(float rate);

    /********* CMR ***********/

    public abstract java.util.Collection orderLines getOrderLines();
    public abstract void setOrderLines(java.util.Collection orderLines);

    ............................

    ...........................
  2. CMR Relationship Problem[ Go to top ]

    The first one is correct