1

I have a

org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: Forms.CarsRentalOrder.OrderUnits

on this code:

@Entity
public class CarsRentalOrder implements Serializable {

   @ManyToMany
   private List<Vehicle>  OrderUnits;

   //methods and variables

}

what is the problem? I saw in some place that list is a collection, and u can make @ManyToMany and @OneToMany attribute.

Thanks!!

Grim
  • 1,938
  • 10
  • 56
  • 123
Eran Pinhas
  • 98
  • 1
  • 9
  • Can you add to that code the getter and setter? – Luciano Jun 21 '12 at 15:07
  • 1
    This question has been asked [a](http://stackoverflow.com/questions/3174379/how-to-map-custom-collection-in-jpa) [few](http://stackoverflow.com/questions/10104946/mapping-queue-collections-in-jpa-hibernate) [times](http://stackoverflow.com/questions/8169196/illegal-attempt-to-map-a-non-collection-as-a-onetomany-manytomany-or-collec) already. – maksimov Jun 21 '12 at 15:10
  • @maksimov: according to the code snippet, the variable is defined as an interface type (assuming there is an import for `java.util.List` here). It's possible that the snippet here is inaccurate, and this is a case of the problem you link to. But if the snippet is accurate, this must be a different problem. – Tom Anderson Jun 21 '12 at 15:40
  • @TomAnderson I've linked to three different questions to motivate OP to do some research. – maksimov Jun 21 '12 at 15:43

0 Answers0