2 Replies Latest reply on Feb 23, 2006 11:28 AM by aidan davis

    Collection not yet supported

    aidan davis Newbie

      I'm trying to get three simple beans to map to each other and am getting the following exception (v4.03SP1 EJB RFC 5):

      (InvocationTargetException).....

      Caused by: org.hibernate.AnnotationException: com.sms.srs.entity.Attribute collection not yet supported: com.sms.srs.entity.AttributeNameattr
      at org.hibernate.cfg.annotations.CollectionBinder.getCollectionBinder(CollectionBinder.java:197)
      at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1175)
      at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:629)
      at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:276)


      The classes involved are:

      @Entity
      @Table (name="ship")
      public class Ship {
      
       public int getImo() {
       return imo;
       }
      
       public void setImo(int imo) {
       this.imo = imo;
       }
      
       @Id @GeneratedValue(strategy= GenerationType.AUTO)
       public int getId() {
       return id;
       }
      
       public void setId(int id) {
       this.id = id;
       }
      
       @CollectionOfElements
       public Collection<Attribute> getAttributes() {
       return attributes;
       }
      
       public void setAttributes(Collection<Attribute> attributes) {
       this.attributes = attributes;
       }
      
       private int imo;
       private int id;
       private Collection<Attribute> attributes;
      
      
      
      }
      


      @Entity
      @Embeddable
      @Table (name="attribute")
      public class Attribute {
      
       @Id @GeneratedValue(strategy= GenerationType.AUTO)
       public int getId() {
       return id;
       }
      
       public void setId(int id) {
       this.id = id;
       }
      
       @ManyToOne
       @JoinColumn(name = "id")
       public AttributeName getNameid() {
       return nameid;
       }
      
       public void setNameid(AttributeName nameid) {
       this.nameid = nameid;
       }
      
       public String getValue() {
       return value;
       }
      
       public void setValue(String value) {
       this.value = value;
       }
      
       @ManyToOne
       @JoinColumn(name = "id")
       public Ship getShip() {
       return ship;
       }
      
       public void setShip(Ship ship) {
       this.ship = ship;
       }
      
       public long getStartdate() {
       return startdate;
       }
      
       public void setStartdate(long startdate) {
       this.startdate = startdate;
       }
      
       public long getEnddate() {
       return enddate;
       }
      
       public void setEnddate(long enddate) {
       this.enddate = enddate;
       }
      
       private Ship ship;
       private int id;
       private AttributeName nameid;
       private String value;
       private long startdate;
       private long enddate;
      
      }
      


      
      @Entity
      @Table (name="attributename")
      public class AttributeName {
      
       @Id @GeneratedValue(strategy= GenerationType.AUTO)
       public int getId() {
       return id;
       }
      
       public void setId(int id) {
       this.id = id;
       }
      
       //Name of the attribute
       public String getName() {
       return name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
       @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="order")
       public Attribute getAttr() {
       return attr;
       }
      
       public void setAttr(Attribute attr) {
       this.attr = attr;
       }
      
       private Attribute attr;
       private int id;
       private String name;
      
      }
      


      With my persistence.xml:

      <persistence>
       <persistence-unit name="srsentity">
       <jta-data-source>java:/MySqlDS</jta-data-source>
      
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       </properties>
       </persistence-unit>
      </persistence>
      


      According to the hibernate annotation documentation, if I use a collection of elements, I should use @CollectionOfElements instead of @OneToMany.... because the EJB spec does not support them...which I'm doing (a Ship has a collection of Attribute)

      I'd really appreciate some help here.

      Thanks.