-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Annotations - problem with collections
PostPosted: Fri Sep 18, 2009 7:58 am 
Newbie

Joined: Fri Aug 14, 2009 8:06 am
Posts: 19
Hi there,

I've created 2 classes in which I have a collection of elements. With one class there is no problem, with the other I get an exception that Hibernate can not determine the type of the collection. Could it have something to do with the fact that one is bi-directional while the other is not? The bi-directional one works by the way.

Here is the code of the classes (slimmed down):

The first one works just fine:

Code:
@Entity
@SequenceGenerator(name = "SEQ_DATAITEM", sequenceName = "dataitem_sequence")
public class DataItem implements Comparable<DataItem>, Serializable, DataChangeListener {
   private static final long serialVersionUID = 1L;

   private Long id;
   private DataItem parent;
   private final UniqueList<DataItem> subData = new UniqueList<DataItem>();

   protected DataItem() {
      super(); // Used by Hibernate
   }

   @Id
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_DATAITEM")
   public Long getId() {
      return id;
   }

   protected void setId(Long id) {
      this.id = id;
   }

   @ManyToOne
   public DataItem getParent() {
      return parent;
   }

   protected void setParent(DataItem parent) {
      this.parent = parent;
   }

   @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent")
   public List<DataItem> getAllSubData() {
      return subData;
   }

   protected void setAllSubData(List<DataItem> subData) {
      this.subData.clear();
      this.subData.addAll(subData);
   }
}


This one generates the error:

Initial SessionFactory creation failed.org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: PostureAspects, for columns: [org.hibernate.mapping.Column(accents)]

Code:
@Entity
@SequenceGenerator(name = "SEQ_POSTURE_ASPECTS", sequenceName = "postureAspects_sequence")
public class PostureAspects extends PersistentObject implements MonitoreableObjectChangeListener {
   private UniqueList<DataItem> accents = new UniqueList<DataItem>();

   PostureAspects() {
   }

   @Override
   @Id
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_POSTURE_ASPECTS")
   public Long getId() {
      return super.getId();
   }

   @OneToMany
   @JoinTable(name = "ExerciseAccents", joinColumns = @JoinColumn(name = "postureAspects_id"), inverseJoinColumns = @JoinColumn(name = "accent_id"))
   protected void setAccents(Set<DataItem> accents) {
      this.accents.clear();
      this.accents.addAll(accents);
   }

   /**
    * @return The accents
    */
   public Set<DataItem> getAccents() {
      return accents;
   }
}


At first I thought that it might have something to do with the fact that UniqueList is not a collection supported by Hibernate but then things should not work in the first class either.

Any help with this would be greatly appreciated.

Cheers,
Stef


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.