3 Replies Latest reply on Nov 23, 2002 10:45 AM by neitzel1

    Should Bean classes be developed as 'abstract'

    qmqasim

      The examples in 'Enterprise JavaBeans' book by Richard Monson-Haefel implements entity beans as abstract classes.

      So I did one example where I declared my entity bean as abstract. So the code looked something like:

      public abstract class CabinBean
      implements javax.ejb.EntityBean
      {


      public abstract void setName(String name);
      public abstract String getName();
      ......

      However, when I deployed it into JBoss I got a error message saying that entity beans cannot be declared as abstract.

      So I am a bit confused. Do they need to be declared as abstract or not.

      regards

        • 1. Re: Should Bean classes be developed as 'abstract'
          tthiele

          I don't know the actual issue of the Monson-Haefel book. AFAIK an EJB can't be abstract. Either you must derive your CabinBean class to a
          non abstract class e.g. CabinCMP manually or let it to a tool like xdoclet. Please refer to the Getting Started Documentation for JBoss and the XDoclet (sourceforge) Documentation for this topic.

          Regards
          Tilo

          • 2. Re: Should Bean classes be developed as 'abstract'
            andyjeff

            My understanding is that with EJB2.0 (JBoss 3.0) you have to declare classes as abstract, and declare the set/get methods as abstract. In EJB1.1 this was NOT the case. This was a change in the EJB2.0 introduction. The OReilly book (issue 3) refers (almost completely) to EJB2.0, hence what you have read. This applies to CMP entity beans anyway.

            HTH

            • 3. Re: Should Bean classes be developed as 'abstract'
              neitzel1

              AN EJB cannot be abstract? I think, that this is wrong. When I look at my Beans I will always find:

              public abstract class MyBean implements EntityBean {
              ...
              public abstract MyType getMyField();
              public abstract void setMyField(MyType value);
              ...
              }

              And I think that this is the normal way, to write a EB.

              This is also described in the JBoss Workbook. Just have a look at http://www.oreilly.com/catalog/entjbeans3/workbooks/

              Konrad