1 Reply Latest reply on Jul 6, 2005 4:23 AM by Jan Arend Jansen

    EJB3 @EmbeddableSuperclass

    Jan Arend Jansen Newbie

      I've tried to do the following:

      @EmbeddableSuperclass
      public class DomainObject implements Serializable
      {
       private Long id;
      
       public Long getId()
       {
       return id;
       }
      
       public void setId(Long id)
       {
       this.id = id;
       }
      }
      
      @Entity
      public class User extends DomainObject
      {
       private String name;
      
       etc...
      }
      


      I was hoping that I could store the Id field in the layer supertype, because it is the same code for all entity beans.

      This results in an error, however:

      org.hibernate.AnnotationException: No identifier specified for entity: User




        • 1. Re: EJB3 @EmbeddableSuperclass
          Jan Arend Jansen Newbie

          Oops. The code fragement should be:

          @EmbeddableSuperclass
          public class DomainObject implements Serializable
          {
           private Long id;
          
           @Id (generate = GeneratorType.AUTO)
           public Long getId()
           {
           return id;
           }
          
           public void setId(Long id)
           {
           this.id = id;
           }
          }
          
          @Entity
          public class User extends DomainObject
          {
           private String name;
          
           etc...
          }