7 Replies Latest reply on Jul 23, 2005 8:36 PM by Emmanuel Bernard

    Why ? ...

    Mihail G. Meleca Newbie

      Why @EmbeddableSuperclass doesn't works without @Entity annotation ??? This leads to creation of an empty table in DB.

      @Entity(access = AccessType.FIELD)
      // from now we MUST specify @Id field and SUPERCLASS table will be created
      @EmbeddableSuperclass
      public abstract class SuperClass {

      @Id(generate = GeneratorType.TABLE)
      @Column(name = "ID") // mapped in empty SUPERCLASS table
      private int id = -1;

      @Column(name = "SOME_VALUE") // mapped in empty SUPERCLASS table
      private String someValue = null;

      // Constructors, Get & Set methods here
      // ...
      }

      @Entity(access = AccessType.FIELD)
      public class ChildClass extends SuperClass {

      // ID and SOME_VALUE are inherited and REmapped in CHILDCLASS table

      @Column(name = "ANOTHER_VALUE") // also mapped in CHILDCLASS table
      private String anotherValue = null;

      // Constructors, Get & Set methods here
      // ...
      }

      All this situation isn't correct. If You have a look at chapter 2.1.9.3 of JSR220 Java Persistence API (Public Draft) You will see a very good example of CORRECT use of @EmbeddableSuperclass which doesn't work in JBoss + EJB3 Beta1.

      It's a BUG ???

      Thanks.