2 Replies Latest reply on Oct 4, 2002 8:07 AM by xjnxjn

    JBoss and derived entity beans

      Hi,

      i would like to use a DefaultEntityBean, for example
      to log creation date/change date for all derived beans
      automatically. The DefaultBean itself will not be
      instantiated direct.


      public abstract class DefaultEntityBean
      implements EntityBean
      {
      /**
      * creation date
      */
      public abstract Date getCreateDate();
      public abstract void setCreateDate( Date date );

      /**
      * date last changed
      */
      public abstract Date getChangeDate();
      public abstract void setChangeDate( Date date );

      ... some methods
      }

      My TestBean :

      public abstract class MandantBean
      extends DefaultEntityBean
      {
      public abstract String getMand();
      public abstract void setMand( String mand );

      ... some methods
      }


      Compiling and deploying works well with JBoss,
      but JBoss will see only the field Mand for the
      MandantBean and not the fields CreateDate and ChangeDate from the superclass.

      The same works fine for SUN J2EE RI !

      Has anybody any idea about this with JBoss ?

      thx

        • 1. Re: JBoss and derived entity beans
          hezekiel

          Could you post an example showing how the fields - not just the methods are used. I've inherited most of my entity beans from common (abstract) base with no problems. Remember that the fields are accessed through object's static type, and methods through it's dynamic type ->

          class base
          {
          String printA() { system.out.println(a); }
          public int a = 10;
          }
          class derived extends base
          {
          public int a = 20;
          }
          base b = new derived();
          derived d = new derived();
          b.printA(); will print the value 10
          d.printA(); will also print the value 10

          • 2. Re: JBoss and derived entity beans

            Hi,

            i only use CMP 2.x. Fields are always accessed by the
            getter/setter methods, either direct or by reflection.

            I will also use only the default SQL-mapping from jboss without a jaws or jdbc mapping, to keep it as simple as
            possible.

            Using 'create table on deploy' results in a table without
            the fields from the derived classes.

            So may be only the default mapping in jboss does not see the fields from the derived classes ?