2 Replies Latest reply on Mar 7, 2006 5:27 AM by Roberto Colmegna

    MappedSuperclass problem with SequenceGenerator

    Roberto Colmegna Newbie

      Hi,

      I'm trying to create an "IdEntityBean" superclass:

      package test.ejb.entity;

      import java.util.*;
      import javax.persistence.*;

      @MappedSuperclass
      public abstract class IdEntityBean {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO, generator = "Seq")
      Integer id;
      public Integer getId() { return id;}
      }



      I can extend another class from this one:

      package test.ejb.entity;

      import java.util.*;
      import javax.persistence.*;
      import javax.ejb.*;

      @Entity
      @Remote
      @Inheritance
      @Table(name="a")

      @NamedQuery(
      name="ABean.findAll",
      query="SELECT o FROM ABean o ORDER BY o.m_sInfo DESC"
      )

      public class ABean extends IdEntityBean {
      @SequenceGenerator(name = "AlfaSeq", sequenceName = "Seq")

      @Column(name="info")
      String m_sInfo;

      @PrePersist
      public void setCreateInfo() {
      m_sInfo = "";
      }

      public String getInfo() { return m_sInfo;}
      public void setInfo(String info) { m_sInfo = info;}
      }


      but when I deploy I obtain this error:

      2006-03-07 11:00:11,624 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRe
      pository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@333b2e,
      cl=org.jboss.mx.loading.UnifiedClassLoader3@b8fba5{ url=null ,addedOrder=0}
      2006-03-07 11:00:11,624 DEBUG [org.hibernate.cfg.AnnotationBinder] Processing an
      notations of test.ejb.entity.ABean.id
      2006-03-07 11:00:11,624 DEBUG [org.hibernate.cfg.Ejb3Column] Binding column id u
      nique false
      2006-03-07 11:00:11,624 DEBUG [org.hibernate.cfg.AnnotationBinder] id is an id
      2006-03-07 11:00:11,624 DEBUG [org.hibernate.cfg.annotations.SimpleValueBinder]
      building SimpleValue for id
      2006-03-07 11:00:11,624 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Starting f
      ailed persistence.units:ear=test.ear.ear,jar=test-ear.jar.jar,unitName=TestPersi
      stenceManager
      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)


      ......

      Caused by: org.hibernate.AnnotationException: Unknown Id.generator: Seq
      at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1595)
      at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(Annotati
      onBinder.java:1065)
      at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:62
      9)



      Any idea?
      TIA
      Roberto Colmegna