0 Replies Latest reply on Sep 6, 2004 9:31 AM by Sathya Sekar

    Urgent help please on EJB implementations

    Sathya Sekar Newbie


      I have a rather common pure-Java scenario which I would like to know is possible in EJBs.

      I have the below class hierarchy :

      AbstractA implements InterfaceA
      MyEntityBeanA extends AbstractA implements EntityBean

      and correspondingly :

      MyEntityBeanB implements EntityBean, InterfaceB

      Now, MyEntityBeanA and MyEntityBeanB are related beans (CMR) . Now I have some generic behaviour in AbstractA which depends on the implementation of the methods of InterfaceB in MyEntityBeanB.

      To clarify, InterfaceB may look as below :

      public interface InterfaceB {
       public String getName();

      and AbstractA may look as below

      public abstract AbstractA implements InterfaceA {
       public abstract Collection getAllRelatedBeans(); // to be implemented by sub-class
       public void justPrintAll() {
       Iterator i = getAllRelatedBeans().iterator();
       while(i.hasNext()) {
       InterfaceB interfaceB = (InterfaceB) i.next();

      The InterfaceB casting obviously fails because what we have in the Collection are the Local interfaces for the MyEntityBeanB bean.

      My query is - is this type of inheritance and abstraction possible in entity beans ? Is there defined way in which I can make it work ? Any suggestions/recommendations would be most welcome.