1 Reply Latest reply on May 14, 2003 5:01 PM by adrian.brock

    EntityBean inheritance problem

    ericmacau

      Hello,

      How can I design the EJB as the following issues:

      Suppose:

      There is a super class "ItemBean"

      The subclasses : BookItemBean, CDItemBean, etc.


      In normal JavaBean, I can define as:

      class BookItemBean extends ItemBean
      class CDItemBean extends ItemBean

      ItemBean itemBook = new BookItemBean();
      ItemBean itemCD = new CDItemBean();

      But how can I use EJB with CMP to design the above relations.


      Best regards,
      Eric

        • 1. Re: EntityBean inheritance problem

          The entity bean model is a component model,
          it does not directly support polymorphism.

          You create bean instances on the home interface

          MyBean bean = home.create(someParameters);

          or find them
          bean = home.findBySomething(someParameters);

          The spec insists the home interface must return
          exactly the remote interface.

          There are some articles on the web about
          how to do it. They all involve doing
          some book-keeping yourself that is normally
          done by the java "this" pointer.

          Regards,
          Adrian